Class: Hyrax::CollectionMemberSearchBuilder
- Inherits:
-
CollectionSearchBuilder
- Object
- SearchBuilder
- CollectionSearchBuilder
- Hyrax::CollectionMemberSearchBuilder
- Includes:
- FilterByType
- Defined in:
- app/search_builders/hyrax/collection_member_search_builder.rb
Overview
This search builder requires that a accessor named “collection” exists in the scope
Instance Attribute Summary collapse
Attributes inherited from CollectionSearchBuilder
Instance Method Summary collapse
-
#initialize(*args, scope: nil, collection: nil, search_includes_models: nil) ⇒ CollectionMemberSearchBuilder
constructor
A new instance of CollectionMemberSearchBuilder.
-
#member_of_collection(solr_parameters) ⇒ Object
include filters into the query to only include the collection memebers.
-
#models ⇒ Object
This overrides the models in FilterByType.
Methods included from FilterByType
Methods inherited from CollectionSearchBuilder
#add_sorting_to_solr, #discovery_permissions, #gated_discovery_filters, #sort_field, #with_access
Constructor Details
#initialize(*args, scope: nil, collection: nil, search_includes_models: nil) ⇒ CollectionMemberSearchBuilder
Returns a new instance of CollectionMemberSearchBuilder.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/search_builders/hyrax/collection_member_search_builder.rb', line 16 def initialize(*args, scope: nil, collection: nil, search_includes_models: nil) @collection = collection @search_includes_models = search_includes_models if args.any? super(*args) else super(scope) end end |
Instance Attribute Details
#collection ⇒ Object
30 31 32 |
# File 'app/search_builders/hyrax/collection_member_search_builder.rb', line 30 def collection @collection || (scope.context[:collection] if scope&.respond_to?(:context)) end |
#search_includes_models ⇒ Object
34 35 36 |
# File 'app/search_builders/hyrax/collection_member_search_builder.rb', line 34 def search_includes_models @search_includes_models || :works end |
Instance Method Details
#member_of_collection(solr_parameters) ⇒ Object
include filters into the query to only include the collection memebers
39 40 41 42 |
# File 'app/search_builders/hyrax/collection_member_search_builder.rb', line 39 def member_of_collection(solr_parameters) solr_parameters[:fq] ||= [] solr_parameters[:fq] << "#{collection_membership_field}:#{collection.id}" end |
#models ⇒ Object
This overrides the models in FilterByType
45 46 47 |
# File 'app/search_builders/hyrax/collection_member_search_builder.rb', line 45 def models work_classes + collection_classes end |