Class: Hyrax::CollectionsService
- Inherits:
-
SearchService
- Object
- SearchService
- Hyrax::CollectionsService
- Defined in:
- app/services/hyrax/collections_service.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#all_search_results(access = nil) {|builder| ... } ⇒ Array<SolrDocument>
Like #search_results, but pages through every matching collection (up to Hyrax.config.solr_max_results).
-
#initialize(context) ⇒ CollectionsService
constructor
A new instance of CollectionsService.
- #search_results(access = nil) ⇒ Object
Constructor Details
#initialize(context) ⇒ CollectionsService
Returns a new instance of CollectionsService.
10 11 12 13 |
# File 'app/services/hyrax/collections_service.rb', line 10 def initialize(context) super(config: context.blacklight_config, user_params: context.params, search_builder_class: self.class.list_search_builder_class, scope: context) @current_ability = context.current_ability end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'app/services/hyrax/collections_service.rb', line 4 def context @context end |
Instance Method Details
#all_search_results(access = nil) {|builder| ... } ⇒ Array<SolrDocument>
Like #search_results, but pages through every matching collection (up to Hyrax.config.solr_max_results). Use this only for surfaces that need the full set, e.g. the "Add to Collection" dropdown where a user must see every collection they can deposit into.
36 37 38 39 40 41 42 43 44 |
# File 'app/services/hyrax/collections_service.rb', line 36 def all_search_results(access = nil) builder = search_builder.with(user_params) builder.with_access(access) if access yield builder if block_given? Hyrax::SolrService.fetch_all do |rows, start| blacklight_config.repository.search(builder.query.merge(rows: rows, start: start)) end end |
#search_results(access = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/hyrax/collections_service.rb', line 16 def search_results(access = nil) response, _docs = super() do |builder| builder.with_access(access) if access builder.rows(100) yield builder if block_given? builder end response.documents end |