Class: Hyrax::CustomQueries::FindManyByAlternateIds

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_serviceObject (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

.queriesObject

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

Parameters:

  • alternate_ids (Enumerator<#to_s>)

    list of ids

Returns:


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