Method: Valkyrie::Persistence::Postgres::QueryService#find_by

Defined in:
lib/valkyrie/persistence/postgres/query_service.rb

#find_by(id:) ⇒ Valkyrie::Resource

Find a record using a Valkyrie ID, and map it to a Valkyrie Resource



49
50
51
52
53
54
55
# File 'lib/valkyrie/persistence/postgres/query_service.rb', line 49

def find_by(id:)
  id = Valkyrie::ID.new(id.to_s) if id.is_a?(String)
  validate_id(id)
  resource_factory.to_resource(object: orm_class.find(id.to_s))
rescue ActiveRecord::RecordNotFound
  raise Valkyrie::Persistence::ObjectNotFoundError
end