Class: Valkyrie::Persistence::Solr::Queries::FindReferencesQuery
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::Queries::FindReferencesQuery
- Defined in:
- lib/valkyrie/persistence/solr/queries/find_references_query.rb
Overview
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#resource_factory ⇒ Object
readonly
Returns the value of attribute resource_factory.
Instance Method Summary collapse
- #each ⇒ Object
- #id ⇒ Object
-
#initialize(resource:, property:, connection:, resource_factory:) ⇒ FindReferencesQuery
constructor
A new instance of FindReferencesQuery.
- #query ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(resource:, property:, connection:, resource_factory:) ⇒ FindReferencesQuery
Returns a new instance of FindReferencesQuery.
7 8 9 10 11 12 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 7 def initialize(resource:, property:, connection:, resource_factory:) @resource = resource @property = property @connection = connection @resource_factory = resource_factory end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 6 def connection @connection end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 6 def property @property end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 6 def resource @resource end |
#resource_factory ⇒ Object (readonly)
Returns the value of attribute resource_factory.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 6 def resource_factory @resource_factory end |
Instance Method Details
#each ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 18 def each docs = DefaultPaginator.new while docs.has_next? params = { q: query, defType: 'lucene' } result = connection.paginate(docs.next_page, docs.per_page, 'select', params: params) docs = result.fetch('response').fetch('docs') docs.each do |doc| yield resource_factory.to_resource(object: doc) end end end |
#id ⇒ Object
34 35 36 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 34 def id resource.id.to_s end |
#query ⇒ Object
30 31 32 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 30 def query "{!join from=#{property}_ssim to=join_id_ssi}id:#{id}" end |
#run ⇒ Object
14 15 16 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 14 def run enum_for(:each) end |