Class: Neo4j::MetaModel::Model

Inherits:
MetaModelBase show all
Defined in:
app/models/neo4j/meta_model/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hierarchicallyObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/neo4j/meta_model/model.rb', line 27

def self.hierarchically
  Hash.new.tap do |result|
    model_parents = Hash[*all.query_as(:model).optional_match("model-[:inherits_from]->(parent)").pluck(:model, :parent).flatten]

    all.query_as(:model).where('NOT(model-[:inherits_from]->())').pluck(:model).each do |model|
      result[model] = {}
    end

    all.query_as(:model).match('p=model-[:inherits_from*1..]->()').pluck('nodes(p)').each do |path|
      path.reverse.inject(result) do |sub_result, model|
        sub_result[model] ||= {}
        sub_result[model]
      end
    end

  end
end

Instance Method Details

#has_associationsObject

def property_ids

  properties(:p).pluck(p: :uuid)
end


23
24
25
# File 'app/models/neo4j/meta_model/model.rb', line 23

def has_associations
  assocs.each_rel.to_a
end

#to_paramObject



15
16
17
# File 'app/models/neo4j/meta_model/model.rb', line 15

def to_param
  self.class_name.tableize
end