Skip to content

Commit

Permalink
♻️ Handle exist? and/or exists? for finding objects
Browse files Browse the repository at this point in the history
See inline comments
  • Loading branch information
jeremyf committed Jan 24, 2024
1 parent b346c74 commit 028069c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/factories/bulkrax/object_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def find
end

def find_by_id
klass.find(attributes[:id]) if klass.exist?(attributes[:id])
# Rails / Ruby upgrade, we moved from :exists? to :exist? However we want to continue (for a
# bit) to support older versions.
method_name = klass.respond_to?(:exist?) ? :exist? : :exists?
klass.find(attributes[:id]) if klass.send(method_name, attributes[:id])
end

def find_or_create
Expand Down

0 comments on commit 028069c

Please sign in to comment.