Class: Hyrax::NestedCollectionsParentSearchBuilder

Inherits:
CollectionSearchBuilder show all
Includes:
FilterByType
Defined in:
app/search_builders/hyrax/nested_collections_parent_search_builder.rb

Overview

Searches for all collections that are parents of a given collection.

Instance Attribute Summary collapse

Attributes inherited from CollectionSearchBuilder

#access

Instance Method Summary collapse

Methods included from FilterByType

#filter_models

Methods inherited from CollectionSearchBuilder

#add_sorting_to_solr, #discovery_permissions, #gated_discovery_filters, #models, #sort_field, #with_access

Constructor Details

#initialize(scope:, child:, page:) ⇒ NestedCollectionsParentSearchBuilder

Returns a new instance of NestedCollectionsParentSearchBuilder.

Parameters:

  • scope (Object)

    Typically the controller object

  • child (ActiveFedora::Base)

    The child collection


11
12
13
14
15
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 11

def initialize(scope:, child:, page:)
  @child = child
  @page = page
  super(scope)
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.


7
8
9
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 7

def child
  @child
end

#limitObject (readonly)

Returns the value of attribute limit.


7
8
9
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 7

def limit
  @limit
end

#pageObject (readonly)

Returns the value of attribute page.


7
8
9
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 7

def page
  @page
end

Instance Method Details

#parent_collections_only(solr_parameters) ⇒ void

This method returns an undefined value.

Filters the query to only include the parent collections

Parameters:

  • solr_parameters (Hash)

23
24
25
26
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 23

def parent_collections_only(solr_parameters)
  solr_parameters[:fq] ||= []
  solr_parameters[:fq] += [Hyrax::SolrQueryBuilderService.construct_query_for_ids(child.member_of_collection_ids)]
end

#with_pagination(solr_parameters) ⇒ void

This method returns an undefined value.

Parameters:

  • solr_parameters (Hash)

33
34
35
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 33

def with_pagination(solr_parameters)
  solr_parameters[:page] = page
end