Commit b8c94661 by Sergey Alekseev

apply actual naming to restore's parameter name

https://github.com/radar/paranoia/blame/1b051ae78793f3b62297b5adbaa9c1d0
0e6726e0/README.md#L154
parent 400e03f6
......@@ -33,13 +33,15 @@ module Paranoia
end
alias :deleted :only_deleted
def restore(id, opts = {})
if ActiveRecord::Base === id
id = id.id
def restore(id_or_ids, opts = {})
ids = Array(id_or_ids).flatten
any_object_instead_of_id = ids.any? { |id| ActiveRecord::Base === id }
if any_object_instead_of_id
ids.map! { |id| ActiveRecord::Base === id ? id.id : id }
ActiveSupport::Deprecation.warn("You are passing an instance of ActiveRecord::Base to `restore`. " \
"Please pass the id of the object by calling `.id`")
end
Array(id).flatten.map { |one_id| only_deleted.find(one_id).restore!(opts) }
ids.map { |id| only_deleted.find(id).restore!(opts) }
end
end
......
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