module Neo4j::ActiveRel

Makes Neo4j Relationships more or less act like ActiveRecord objects. See documentation at github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveRel

Constants

MARSHAL_INSTANCE_VARIABLES

Public Class Methods

inherited(other) click to toggle source
Calls superclass method Neo4j::Shared::inherited
   # File lib/neo4j/active_rel.rb
47 def self.inherited(other)
48   attributes.each_pair do |k, v|
49     other.inherit_property k.to_sym, v.clone, declared_properties[k].options
50   end
51   super
52 end
new(from_node = nil, to_node = nil, args = nil) click to toggle source
Calls superclass method Neo4j::ActiveRel::Property::new
   # File lib/neo4j/active_rel.rb
25 def initialize(from_node = nil, to_node = nil, args = nil)
26   load_nodes(node_or_nil(from_node), node_or_nil(to_node))
27   resolved_args = hash_or_nil(from_node, args)
28   symbol_args = sanitize_input_parameters(resolved_args)
29   super(symbol_args)
30 end

Public Instance Methods

neo4j_obj() click to toggle source
   # File lib/neo4j/active_rel.rb
40 def neo4j_obj
41   _persisted_obj || fail('Tried to access native neo4j object on a non persisted object')
42 end
node_cypher_representation(node) click to toggle source
   # File lib/neo4j/active_rel.rb
32 def node_cypher_representation(node)
33   node_class = node.class
34   id_name = node_class.id_property_name
35   labels = ':' + node_class.mapped_label_names.join(':')
36 
37   "(#{labels} {#{id_name}: #{node.id.inspect}})"
38 end

Private Instance Methods

hash_or_nil(node_or_hash, hash_or_nil) click to toggle source
   # File lib/neo4j/active_rel.rb
63 def hash_or_nil(node_or_hash, hash_or_nil)
64   hash_or_parameter?(node_or_hash) ? node_or_hash : hash_or_nil
65 end
node_or_nil(node) click to toggle source
   # File lib/neo4j/active_rel.rb
59 def node_or_nil(node)
60   node.is_a?(Neo4j::ActiveNode) || node.is_a?(Integer) ? node : nil
61 end