Module: Neo4j::Wrapper::ClassMethods

Defined in:
lib/neo4j-wrapper/class_methods.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) extended(klass)

Creates an alias to the original new method: orig_new



51
52
53
54
55
56
57
58
# File 'lib/neo4j-wrapper/class_methods.rb', line 51

def self.extended(klass)
  klass.instance_eval do
    class << self
      alias_method :orig_new, :new
    end
  end unless klass.respond_to?(:orig_new)
  super
end

Instance Method Details

- (Object) _load_wrapper(node)

Loads the wrapper by using the original new method and initialize it



7
8
9
10
11
# File 'lib/neo4j-wrapper/class_methods.rb', line 7

def _load_wrapper(node)
  wrapped_node = self.orig_new
  wrapped_node.init_on_load(node)
  wrapped_node
end

- (Object) setup_neo4j_subclass(sub_klass)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/neo4j-wrapper/class_methods.rb', line 13

def setup_neo4j_subclass(sub_klass)
  return if self.to_s == sub_klass.to_s
  # make the base class trigger on the sub class nodes
  _indexer.config.trigger_on :_classname => sub_klass.to_s

  sub_klass.inherit_rules_from(self) if sub_klass.respond_to?(:inherit_rules_from)

  if sub_klass.ancestors.include?(Neo4j::NodeMixin)
    setup_node_index(sub_klass)
  else
    setup_rel_index(sub_klass)
  end

  superclass.setup_neo4j_subclass(sub_klass) if superclass.respond_to?(:setup_neo4j_subclass)
end

- (Object) setup_node_index(sub_klass = self)



29
30
31
32
33
34
35
36
37
# File 'lib/neo4j-wrapper/class_methods.rb', line 29

def setup_node_index(sub_klass=self)
  base_class = self
  sub_klass.node_indexer do
    inherit_from base_class unless base_class == sub_klass
    index_names :exact => "#{sub_klass._index_name}_exact", :fulltext => "#{sub_klass._index_name}_fulltext"
    trigger_on :_classname => sub_klass.to_s
    prefix_index_name &sub_klass.method(:index_prefix)
  end
end

- (Object) setup_rel_index(sub_klass = self)



39
40
41
42
43
44
45
46
47
# File 'lib/neo4j-wrapper/class_methods.rb', line 39

def setup_rel_index(sub_klass=self)
  base_class = self
  sub_klass.rel_indexer do
    inherit_from base_class unless base_class == sub_klass
    index_names :exact => "#{sub_klass._index_name}_exact", :fulltext => "#{sub_klass._index_name}_fulltext"
    trigger_on :_classname => sub_klass.to_s
    prefix_index_name &sub_klass.method(:index_prefix)
  end
end