Class: Valkyrie::Persistence::Solr::Queries::FindAllQuery
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::Queries::FindAllQuery
- Defined in:
- lib/valkyrie/persistence/solr/queries/find_all_query.rb
Overview
Responsible for efficiently returning all objects in the solr repository as Resources
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#resource_factory ⇒ Object
readonly
Returns the value of attribute resource_factory.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(connection:, resource_factory:, model: nil) ⇒ FindAllQuery
constructor
A new instance of FindAllQuery.
- #query ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(connection:, resource_factory:, model: nil) ⇒ FindAllQuery
Returns a new instance of FindAllQuery.
7 8 9 10 11 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 7 def initialize(connection:, resource_factory:, model: nil) @connection = connection @resource_factory = resource_factory @model = model end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 6 def connection @connection end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 6 def model @model end |
#resource_factory ⇒ Object (readonly)
Returns the value of attribute resource_factory.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 6 def resource_factory @resource_factory end |
Instance Method Details
#each ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 17 def each docs = DefaultPaginator.new while docs.has_next? docs = connection.paginate(docs.next_page, docs.per_page, "select", params: { q: query })["response"]["docs"] docs.each do |doc| yield resource_factory.to_resource(object: doc) end end end |
#query ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 27 def query if !model "*:*" else "#{Valkyrie::Persistence::Solr::Queries::MODEL}:#{model}" end end |
#run ⇒ Object
13 14 15 |
# File 'lib/valkyrie/persistence/solr/queries/find_all_query.rb', line 13 def run enum_for(:each) end |