Class: Hyrax::CustomQueries::FindManyByAlternateIds
- Inherits:
-
Object
- Object
- Hyrax::CustomQueries::FindManyByAlternateIds
- Defined in:
- app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
Instance Attribute Summary collapse
-
#query_service ⇒ Object
readonly
Returns the value of attribute query_service.
Class Method Summary collapse
-
.queries ⇒ Object
Use: Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: ids).
Instance Method Summary collapse
-
#find_many_by_alternate_ids(alternate_ids:) ⇒ Enumerable<Valkyrie::Resource>, Enumerable<ActiveFedora::Base>
implements a combination of two Valkyrie queries: => find_many_by_ids & find_by_alternate_identifier.
-
#initialize(query_service:) ⇒ FindManyByAlternateIds
constructor
A new instance of FindManyByAlternateIds.
Constructor Details
#initialize(query_service:) ⇒ FindManyByAlternateIds
Returns a new instance of FindManyByAlternateIds.
14 15 16 |
# File 'app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb', line 14 def initialize(query_service:) @query_service = query_service end |
Instance Attribute Details
#query_service ⇒ Object (readonly)
Returns the value of attribute query_service.
12 13 14 |
# File 'app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb', line 12 def query_service @query_service end |
Class Method Details
.queries ⇒ Object
Use:
Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: ids)
8 9 10 |
# File 'app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb', line 8 def self.queries [:find_many_by_alternate_ids] end |
Instance Method Details
#find_many_by_alternate_ids(alternate_ids:) ⇒ Enumerable<Valkyrie::Resource>, Enumerable<ActiveFedora::Base>
implements a combination of two Valkyrie queries:
> find_many_by_ids & find_by_alternate_identifier
23 24 25 26 27 28 29 30 |
# File 'app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb', line 23 def find_many_by_alternate_ids(alternate_ids:) return enum_for(:find_many_by_alternate_ids, alternate_ids: alternate_ids) unless block_given? alternate_ids.uniq do |id| yield query_service.find_by_alternate_identifier(alternate_identifier: id.to_s) end end |