module Neo4j::ActiveNode
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
¶ ↑
-
{Neo4j::ActiveNode::Labels::ClassMethods} defines methods like:
index
andfind
-
{Neo4j::ActiveNode::Persistence::ClassMethods} defines methods like:
create
andcreate!
-
{Neo4j::ActiveNode::Property::ClassMethods} defines methods like:
property
.
@example Create a Ruby wrapper for a Neo4j Node
class Company include Neo4j::ActiveNode 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/neo4j/active_node.rb 98 def self.inherit_id_property(other) 99 return if other.manual_id_property? || !self.id_property? 100 id_prop = self.id_property_info 101 conf = id_prop[:type].empty? && id_prop[:name] != :neo_id ? {auto: :uuid} : id_prop[:type] 102 other.id_property id_prop[:name], conf, true 103 end
inherited(other)
click to toggle source
Calls superclass method
Neo4j::Shared::inherited
# File lib/neo4j/active_node.rb 84 def self.inherited(other) 85 Neo4j::ActiveNode::Labels.clear_wrapped_models 86 87 LOADED_CLASSES << other 88 other.instance_variable_set('@inherited', true) 89 inherit_id_property(other) 90 attributes.each_pair do |k, v| 91 other.inherit_property k.to_sym, v.clone, declared_properties[k].options 92 end 93 94 Neo4j::ActiveNode::Labels.add_wrapped_class(other) 95 super 96 end
inherited?()
click to toggle source
# File lib/neo4j/active_node.rb 80 def self.inherited? 81 !!@inherited 82 end
loaded_classes()
click to toggle source
# File lib/neo4j/active_node.rb 62 def self.loaded_classes 63 LOADED_CLASSES 64 end
new(args = nil)
click to toggle source
Calls superclass method
Neo4j::ActiveNode::Property::new
# File lib/neo4j/active_node.rb 49 def initialize(args = nil) 50 self.class.ensure_id_property_info! # So that we make sure all objects have an id_property 51 52 args = sanitize_input_parameters(args) 53 super(args) 54 end
Public Instance Methods
neo4j_obj()
click to toggle source
# File lib/neo4j/active_node.rb 56 def neo4j_obj 57 _persisted_obj || fail('Tried to access native neo4j object on a non persisted object') 58 end