Class: Hyrax::NestedCollectionsParentSearchBuilder

Inherits:
SearchBuilder
  • Object
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

Instance Method Summary collapse

Methods included from FilterByType

#filter_models

Constructor Details

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

Returns a new instance of NestedCollectionsParentSearchBuilder.

Parameters:

  • Typically (scope)

    the controller object

  • The (child)

    child collection



9
10
11
12
13
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 9

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

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



5
6
7
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 5

def child
  @child
end

#limitObject (readonly)

Returns the value of attribute limit.



5
6
7
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 5

def limit
  @limit
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 5

def page
  @page
end

Instance Method Details

#parent_collections_only(solr_parameters) ⇒ Object

Filters the query to only include the parent collections



16
17
18
19
# File 'app/search_builders/hyrax/nested_collections_parent_search_builder.rb', line 16

def parent_collections_only(solr_parameters)
  solr_parameters[:fq] ||= []
  solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_ids(child.member_of_collection_ids)
end

#with_pagination(solr_parameters) ⇒ Object



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

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