Commit 5257eec4 by Alexey Pokhozhaev

Always return self when restore

parent b1a4a6f2
...@@ -34,11 +34,7 @@ module Paranoia ...@@ -34,11 +34,7 @@ module Paranoia
alias :deleted :only_deleted alias :deleted :only_deleted
def restore(id, opts = {}) def restore(id, opts = {})
if id.is_a?(Array) Array(id).flatten.map { |one_id| only_deleted.find(one_id).restore!(opts) }
id.map { |one_id| restore(one_id, opts) }
else
only_deleted.find(id).restore!(opts)
end
end end
end end
...@@ -97,6 +93,8 @@ module Paranoia ...@@ -97,6 +93,8 @@ module Paranoia
restore_associated_records if opts[:recursive] restore_associated_records if opts[:recursive]
end end
end end
self
end end
alias :restore :restore! alias :restore :restore!
......
...@@ -290,6 +290,13 @@ class ParanoiaTest < test_framework ...@@ -290,6 +290,13 @@ class ParanoiaTest < test_framework
assert_equal false, model.destroyed? assert_equal false, model.destroyed?
end end
def test_restore_on_object_return_self
model = ParanoidModel.create
model.destroy
assert_equal model.class, model.restore.class
end
# Regression test for #92 # Regression test for #92
def test_destroy_twice def test_destroy_twice
model = ParanoidModel.new model = ParanoidModel.new
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment