Class: Hyrax::AbstractTypeRelation
- Inherits:
-
ActiveFedora::Relation
- Object
- ActiveFedora::Relation
- Hyrax::AbstractTypeRelation
show all
- Defined in:
- app/search_builders/hyrax/abstract_type_relation.rb
Defined Under Namespace
Classes: DummyModel
Instance Method Summary
collapse
Constructor Details
#initialize(allowable_types: nil, **opts) ⇒ AbstractTypeRelation
Returns a new instance of AbstractTypeRelation.
4
5
6
7
|
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 4
def initialize(allowable_types: nil, **opts)
@allowable_types = allowable_types
super(DummyModel, opts)
end
|
Instance Method Details
#allowable_types ⇒ Object
9
10
11
12
|
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 9
def allowable_types
@allowable_types ||
raise(NotImplementedException, "Implement allowable_types in a subclass")
end
|
#equivalent_class?(klass) ⇒ Boolean
14
15
16
|
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 14
def equivalent_class?(klass)
allowable_types.include?(klass)
end
|
#search_model_clause ⇒ Object
18
19
20
21
22
23
24
|
# File 'app/search_builders/hyrax/abstract_type_relation.rb', line 18
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
|