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
- MARSHAL_INSTANCE_VARIABLES
Public Class Methods
inherit_id_property(other)
click to toggle source
# File lib/neo4j/active_node.rb 83 def self.inherit_id_property(other) 84 Neo4j::Session.on_next_session_available do |_| 85 next if other.manual_id_property? || !self.id_property? 86 id_prop = self.id_property_info 87 conf = id_prop[:type].empty? ? {auto: :uuid} : id_prop[:type] 88 other.id_property id_prop[:name], conf 89 end 90 end
inherited(other)
click to toggle source
Calls superclass method
Neo4j::Shared::inherited
# File lib/neo4j/active_node.rb 71 def self.inherited(other) 72 Neo4j::ActiveNode::Labels.clear_wrapped_models 73 74 inherit_id_property(other) 75 attributes.each_pair do |k, v| 76 other.inherit_property k.to_sym, v.clone, declared_properties[k].options 77 end 78 79 Neo4j::ActiveNode::Labels.add_wrapped_class(other) 80 super 81 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 args = sanitize_input_parameters(args) 51 super(args) 52 end
Public Instance Methods
neo4j_obj()
click to toggle source
# File lib/neo4j/active_node.rb 54 def neo4j_obj 55 _persisted_obj || fail('Tried to access native neo4j object on a non persisted object') 56 end