Class: Hyrax::ValkyrieAbstractTypeRelation
- Inherits:
-
Object
- Object
- Hyrax::ValkyrieAbstractTypeRelation
- Defined in:
- app/search_builders/hyrax/valkyrie_abstract_type_relation.rb
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object
- #allowable_types ⇒ Object
- #count ⇒ Object
- #equivalent_class?(klass) ⇒ Boolean
-
#initialize(allowable_types: nil, _opts: {}) ⇒ ValkyrieAbstractTypeRelation
constructor
A new instance of ValkyrieAbstractTypeRelation.
- #where(hash) ⇒ Object
Constructor Details
#initialize(allowable_types: nil, _opts: {}) ⇒ ValkyrieAbstractTypeRelation
Returns a new instance of ValkyrieAbstractTypeRelation.
5 6 7 |
# File 'app/search_builders/hyrax/valkyrie_abstract_type_relation.rb', line 5 def initialize(allowable_types: nil, _opts: {}) @allowable_types = allowable_types end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/search_builders/hyrax/valkyrie_abstract_type_relation.rb', line 26 def ==(other) case other when Relation other.where_values == where_values when Array to_a == other end end |
#allowable_types ⇒ Object
9 10 11 12 |
# File 'app/search_builders/hyrax/valkyrie_abstract_type_relation.rb', line 9 def allowable_types @allowable_types.present? || raise(NotImplementedException, "Implement allowable_types in a subclass") end |
#count ⇒ Object
18 19 20 |
# File 'app/search_builders/hyrax/valkyrie_abstract_type_relation.rb', line 18 def count Hyrax.query_service.custom_queries.find_count_by(models: allowable_types) end |
#equivalent_class?(klass) ⇒ Boolean
14 15 16 |
# File 'app/search_builders/hyrax/valkyrie_abstract_type_relation.rb', line 14 def equivalent_class?(klass) allowable_types.include?(klass) end |
#where(hash) ⇒ Object
22 23 24 |
# File 'app/search_builders/hyrax/valkyrie_abstract_type_relation.rb', line 22 def where(hash) Hyrax.query_service.find_references_by(resource: hash.values.first, property: hash.keys.first) end |