Skip to content

Commit

Permalink
apply actual naming to restore's parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-alekseev committed Feb 17, 2015
1 parent 400e03f commit b8c9466
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ def only_deleted
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

Expand Down

0 comments on commit b8c9466

Please sign in to comment.