module ActiveGraph::Node
Makes Neo4j nodes and relationships behave like ActiveRecord objects. By including this module in your class it will create a mapping for the node to your ruby class by using a Neo4j Label with the same name as the class. When the node is loaded from the database it will check if there is a ruby class for the labels it has. If there Ruby class with the same name as the label then the Neo4j node will be wrapped in a new object of that class.
ClassMethods
¶ ↑
-
{ActiveGraph::Node::Labels::ClassMethods} defines methods like:
index
andfind
-
{ActiveGraph::Node::Persistence::ClassMethods} defines methods like:
create
andcreate!
-
{ActiveGraph::Node::Property::ClassMethods} defines methods like:
property
.
@example Create a Ruby wrapper for a Neo4j Node
class Company include ActiveGraph::Node property :name end company = Company.new company.name = 'My Company AB' Company.save
Constants
- LOADED_CLASSES
- MARSHAL_INSTANCE_VARIABLES
Public Class Methods
inherit_id_property(other)
click to toggle source
# File lib/active_graph/node.rb 100 def self.inherit_id_property(other) 101 return if other.manual_id_property? || !self.id_property? 102 id_prop = self.id_property_info 103 conf = id_prop[:type].empty? && id_prop[:name] != :neo_id ? {auto: :uuid} : id_prop[:type] 104 other.id_property id_prop[:name], conf, true 105 end
inherited(other)
click to toggle source
Calls superclass method
ActiveGraph::Shared::inherited
# File lib/active_graph/node.rb 86 def self.inherited(other) 87 ActiveGraph::Node::Labels.clear_wrapped_models 88 89 LOADED_CLASSES << other 90 other.instance_variable_set('@inherited', true) 91 inherit_id_property(other) 92 attributes.each_pair do |k, v| 93 other.inherit_property k.to_sym, v.clone, declared_properties[k].options 94 end 95 96 ActiveGraph::Node::Labels.add_wrapped_class(other) 97 super 98 end
inherited?()
click to toggle source
# File lib/active_graph/node.rb 82 def self.inherited? 83 !!@inherited 84 end
loaded_classes()
click to toggle source
# File lib/active_graph/node.rb 64 def self.loaded_classes 65 LOADED_CLASSES 66 end
new(args = nil)
click to toggle source
Calls superclass method
ActiveGraph::Node::Property::new
# File lib/active_graph/node.rb 51 def initialize(args = nil) 52 self.class.ensure_id_property_info! # So that we make sure all objects have an id_property 53 54 args = sanitize_input_parameters(args) 55 super(args) 56 end
Public Instance Methods
neo4j_obj()
click to toggle source
# File lib/active_graph/node.rb 58 def neo4j_obj 59 _persisted_obj || fail('Tried to access native neo4j object on a non persisted object') 60 end