module ActiveGraph::Relationship
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
ActiveGraph::Shared::inherited
# File lib/active_graph/relationship.rb 48 def self.inherited(other) 49 attributes.each_pair do |k, v| 50 other.inherit_property k.to_sym, v.clone, declared_properties[k].options 51 end 52 super 53 end
new(from_node = nil, to_node = nil, args = nil)
click to toggle source
Calls superclass method
ActiveGraph::Relationship::Property::new
# File lib/active_graph/relationship.rb 26 def initialize(from_node = nil, to_node = nil, args = nil) 27 load_nodes(node_or_nil(from_node), node_or_nil(to_node)) 28 resolved_args = hash_or_nil(from_node, args) 29 symbol_args = sanitize_input_parameters(resolved_args) 30 super(symbol_args) 31 end
Public Instance Methods
neo4j_obj()
click to toggle source
# File lib/active_graph/relationship.rb 41 def neo4j_obj 42 _persisted_obj || fail('Tried to access native neo4j object on a non persisted object') 43 end
node_cypher_representation(node)
click to toggle source
# File lib/active_graph/relationship.rb 33 def node_cypher_representation(node) 34 node_class = node.class 35 id_name = node_class.id_property_name 36 labels = ':' + node_class.mapped_label_names.join(':') 37 38 "(#{labels} {#{id_name}: #{node.id.inspect}})" 39 end
Private Instance Methods
hash_or_nil(node_or_hash, hash_or_nil)
click to toggle source
# File lib/active_graph/relationship.rb 64 def hash_or_nil(node_or_hash, hash_or_nil) 65 hash_or_parameter?(node_or_hash) ? node_or_hash : hash_or_nil 66 end
node_or_nil(node)
click to toggle source
# File lib/active_graph/relationship.rb 60 def node_or_nil(node) 61 node.is_a?(ActiveGraph::Node) || node.is_a?(Integer) ? node : nil 62 end