Class: Hyrax::ValkyrieAbstractTypeRelation

Inherits:
Object
  • Object
show all
Defined in:
app/search_builders/hyrax/valkyrie_abstract_type_relation.rb

Direct Known Subclasses

ValkyrieWorkRelation

Instance Method Summary collapse

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_typesObject



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

#countObject



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

Returns:

  • (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