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.



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

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

Instance Method Details

#allowable_typesObject

Raises:

  • (NotImplementedException)


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

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

#equivalent_class?(klass) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#search_model_clauseObject



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

def search_model_clause
  clauses = allowable_types.map do |k|
    ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: k.to_s)
  end
  clauses.size == 1 ? clauses.first : "(#{clauses.join(' OR ')})"
end