Sha256: 378a81a8729f35d14d83e32c4cd10cb2271d0a51e7f49d4949fc6267c1ac51e5

Contents?: true

Size: 933 Bytes

Versions: 12

Compression:

Stored size: 933 Bytes

Contents

module Hyrax
  # This search builder requires that a accessor named "collection" exists in the scope
  # TODO it would be better to pass collection_id in.
  class CollectionMemberSearchBuilder < ::SearchBuilder
    include Hyrax::FilterByType

    class_attribute :collection_membership_field
    self.collection_membership_field = 'member_of_collection_ids_ssim'

    # Defines which search_params_logic should be used when searching for Collection members
    self.default_processor_chain += [:member_of_collection]

    delegate :collection, to: :scope

    # include filters into the query to only include the collection memebers
    def member_of_collection(solr_parameters)
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << "#{collection_membership_field}:#{collection_id}"
    end

    private

      def collection_id
        collection.id || raise("Collection does not have an identifier")
      end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.2 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.1 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.rc3 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.rc2 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.rc1 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.beta5 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.beta4 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.beta3 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.beta2 app/search_builders/hyrax/collection_member_search_builder.rb
hyrax-2.0.0.beta1 app/search_builders/hyrax/collection_member_search_builder.rb