Class: Hyrax::Collections::CollectionMemberSearchService
- Inherits:
-
SearchService
- Object
- Blacklight::SearchService
- SearchService
- Hyrax::Collections::CollectionMemberSearchService
- Defined in:
- app/services/hyrax/collections/collection_member_search_service.rb
Overview
Retrieves collection members
Instance Method Summary collapse
-
#available_member_subcollections ⇒ Blacklight::Solr::Response
Collections which are members of the given collection.
-
#available_member_work_ids ⇒ Blacklight::Solr::Response
Work ids of the works which are members of the given collection.
-
#available_member_works ⇒ Blacklight::Solr::Response
Works which are members of the given collection.
-
#initialize(scope:, collection:, params:, user_params: nil, current_ability: nil, search_builder_class: Hyrax::CollectionMemberSearchBuilder) ⇒ CollectionMemberSearchService
constructor
A new instance of CollectionMemberSearchService.
Constructor Details
#initialize(scope:, collection:, params:, user_params: nil, current_ability: nil, search_builder_class: Hyrax::CollectionMemberSearchBuilder) ⇒ CollectionMemberSearchService
Returns a new instance of CollectionMemberSearchService.
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/hyrax/collections/collection_member_search_service.rb', line 14 def initialize(scope:, collection:, params:, user_params: nil, current_ability: nil, search_builder_class: Hyrax::CollectionMemberSearchBuilder) # rubocop:disable Metrics/ParameterLists super( config: scope.blacklight_config, user_params: user_params || params, collection: collection, scope: scope, current_ability: current_ability || scope.current_ability, search_builder_class: search_builder_class ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hyrax::SearchService
Instance Method Details
#available_member_subcollections ⇒ Blacklight::Solr::Response
Collections which are members of the given collection
31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/hyrax/collections/collection_member_search_service.rb', line 31 def available_member_subcollections response, _docs = search_results do |builder| # To differentiate current page for works vs subcollections, we have to use a sub_collection_page # param. Map this to the page param before querying for subcollections, if it's present builder.page(user_params[:sub_collection_page]) builder.search_includes_models = :collections builder end response end |
#available_member_work_ids ⇒ Blacklight::Solr::Response
Work ids of the works which are members of the given collection
64 65 66 67 68 69 70 71 |
# File 'app/services/hyrax/collections/collection_member_search_service.rb', line 64 def available_member_work_ids response, _docs = search_results do |builder| builder.search_includes_models = :works builder.merge(fl: 'id') builder end response end |
#available_member_works ⇒ Blacklight::Solr::Response
Works which are members of the given collection
48 49 50 51 52 53 54 55 56 |
# File 'app/services/hyrax/collections/collection_member_search_service.rb', line 48 def available_member_works sort_field = user_params[:sort] response, _docs = search_results do |builder| builder.search_includes_models = :works builder.merge(sort: sort_field) builder end response end |