Skip to content

Commit

Permalink
Refactored resource destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed May 29, 2010
1 parent e63dd70 commit f5f2599
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/dm-core/resource.rb
Expand Up @@ -442,10 +442,10 @@ def destroy
return true if destroyed?
catch :halt do
before_destroy_hook
retval = _destroy
_destroy
after_destroy_hook
retval
end
destroyed?
end

# Destroy the instance, remove it from the repository, bypassing hooks
Expand All @@ -457,6 +457,7 @@ def destroy
def destroy!
return true if destroyed?
_destroy(false)
destroyed?
end

# Compares another Resource for equality
Expand Down Expand Up @@ -1001,11 +1002,14 @@ def update_with_hooks
end
end

# Destroy the resource
#
# @return [undefined]
#
# @api private
def _destroy(execute_hooks = true)
deleted = persisted_state.delete
self.persisted_state = deleted.commit
true
self.persisted_state = persisted_state.delete
_persist
end

# @api private
Expand Down

0 comments on commit f5f2599

Please sign in to comment.