module Neo4j::Node::Wrapper
The wrapping process is what transforms a raw CypherNode or EmbeddedNode from Neo4j::Core
into a healthy ActiveNode (or ActiveRel) object.
Constants
- CONSTANTS_FOR_LABELS_CACHE
Only load classes once for performance
Private Class Methods
association_model_namespace()
click to toggle source
# File lib/neo4j/active_node/node_wrapper.rb 48 def self.association_model_namespace 49 Neo4j::Config.association_model_namespace_string 50 end
constant_for_label(label)
click to toggle source
# File lib/neo4j/active_node/node_wrapper.rb 32 def self.constant_for_label(label) 33 CONSTANTS_FOR_LABELS_CACHE[label] || CONSTANTS_FOR_LABELS_CACHE[label] = constantized_label(label) 34 end
constantized_label(label)
click to toggle source
# File lib/neo4j/active_node/node_wrapper.rb 36 def self.constantized_label(label) 37 "#{association_model_namespace}::#{label}".constantize 38 rescue NameError 39 nil 40 end
populate_constants_for_labels_cache(model_class, labels)
click to toggle source
# File lib/neo4j/active_node/node_wrapper.rb 42 def self.populate_constants_for_labels_cache(model_class, labels) 43 labels.each do |label| 44 CONSTANTS_FOR_LABELS_CACHE[label] = model_class if CONSTANTS_FOR_LABELS_CACHE[label].nil? 45 end 46 end
Public Instance Methods
class_to_wrap()
click to toggle source
# File lib/neo4j/active_node/node_wrapper.rb 16 def class_to_wrap 17 load_classes_from_labels 18 Neo4j::ActiveNode::Labels.model_for_labels(labels).tap do |model_class| 19 Neo4j::Node::Wrapper.populate_constants_for_labels_cache(model_class, labels) 20 end 21 end
wrapper()
click to toggle source
this is a plugin in the neo4j-core so that the Ruby wrapper will be wrapped around the Neo4j::Node
objects
# File lib/neo4j/active_node/node_wrapper.rb 7 def wrapper 8 found_class = class_to_wrap 9 return self if not found_class 10 11 found_class.new.tap do |wrapped_node| 12 wrapped_node.init_on_load(self, self.props) 13 end 14 end
Private Instance Methods
load_classes_from_labels()
click to toggle source
# File lib/neo4j/active_node/node_wrapper.rb 25 def load_classes_from_labels 26 labels.each { |label| Neo4j::Node::Wrapper.constant_for_label(label) } 27 end