Skip to content

Commit

Permalink
Rearrange code to allow fallback to alternative_id
Browse files Browse the repository at this point in the history
  • Loading branch information
laritakr committed Oct 15, 2024
1 parent 1e73fb6 commit a27e04c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/hyrax/valkyrie_can_can_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ def self.for_class?(member_class)
#
# @raise Hyrax::ObjectNotFoundError
def self.find(_model_class, id)
Hyrax.query_service.find_by(id: id) ||
Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id)
self.find_by(id: id) ||
Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id)
rescue Valkyrie::Persistence::ObjectNotFoundError => err
raise Hyrax::ObjectNotFoundError, err.message
end

def self.find_by(id:)
Hyrax.query_service.find_by(id: id)
rescue Valkyrie::Persistence::ObjectNotFoundError
end
end
end

0 comments on commit a27e04c

Please sign in to comment.