Permalink
Browse files

destroy and restore should return self

  • Loading branch information...
1 parent f300e22 commit 4beab16956fd9c18bb2769ab816ec4818948ad8b Brent Dillingham committed Jun 11, 2009
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/is_paranoid.rb
View
4 lib/is_paranoid.rb
@@ -185,6 +185,7 @@ def destroy_without_callbacks
"#{destroyed_field} = #{self.class.connection.quote(( field_destroyed.respond_to?(:call) ? field_destroyed.call : field_destroyed))}",
"id = #{self.id}"
)
+ self
end
# Override the default destroy to allow us to flag deleted_at.
@@ -196,13 +197,14 @@ def destroy
return false if callback(:before_destroy) == false
result = destroy_without_callbacks
callback(:after_destroy)
- result
+ self
end
# Set deleted_at flag on a model to field_not_destroyed, effectively
# undoing the soft-deletion.
def restore(options = {})
self.class.restore(id, options)
+ self
end
end

0 comments on commit 4beab16

Please sign in to comment.