Class: Hyrax::AbstractTypeRelation

Inherits:
ActiveFedora::Relation
  • Object
show all
Defined in:
app/search_builders/hyrax/abstract_type_relation.rb

Direct Known Subclasses

ExposedModelsRelation, WorkRelation

Defined Under Namespace

Classes: DummyModel

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AbstractTypeRelation

Returns a new instance of AbstractTypeRelation.


4
5
6
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 4

def initialize(opts = {})
  super(DummyModel, opts)
end

Instance Method Details

#allowable_typesObject

Raises:

  • (NotImplementedException)

8
9
10
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 8

def allowable_types
  raise NotImplementedException, "Implement allowable_types in a subclass"
end

#equivalent_class?(klass) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 12

def equivalent_class?(klass)
  allowable_types.include?(klass)
end

#search_model_clauseObject


16
17
18
19
20
21
22
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 16

def search_model_clause
  clauses = allowable_types.map do |k|
    ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: k.to_s)
  end
  # empty array returns nil, AF finder method handles it properly, see hyrax issue #2844
  clauses.size <= 1 ? clauses.first : "(#{clauses.join(' OR ')})"
end