Module: N4j::Node
- Extended by:
- ActiveSupport::Concern
- Included in:
- GenericNode
- Defined in:
- lib/n4j/node.rb
Defined Under Namespace
Modules: AutoRelate, ClassMethods
Instance Method Summary
collapse
Instance Method Details
#body_hash ⇒ Object
41
42
43
|
# File 'lib/n4j/node.rb', line 41
def body_hash
data
end
|
#clear_new_relationships! ⇒ Object
87
88
89
|
# File 'lib/n4j/node.rb', line 87
def clear_new_relationships!
@new_relationships = []
end
|
#connected_unsaved ⇒ Object
49
50
51
|
# File 'lib/n4j/node.rb', line 49
def connected_unsaved
new_relationships
end
|
#create_path ⇒ Object
37
38
39
|
# File 'lib/n4j/node.rb', line 37
def create_path
'/node'
end
|
#cypher(opts = {}) ⇒ Object
78
79
80
81
|
# File 'lib/n4j/node.rb', line 78
def cypher(opts = {})
defaults = {:start => self}
N4j::Cypher.new(defaults.merge(opts))
end
|
#dependent ⇒ Object
45
46
47
|
# File 'lib/n4j/node.rb', line 45
def dependent
relationships
end
|
#entity_type ⇒ Object
68
69
70
|
# File 'lib/n4j/node.rb', line 68
def entity_type
'node'
end
|
#initialize(hsh) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/n4j/node.rb', line 30
def initialize(hsh)
super(hsh)
unless N4j.neo4j_hash?(hsh)
self.data = hsh.dup
end
end
|
#new_relationships ⇒ Object
83
84
85
|
# File 'lib/n4j/node.rb', line 83
def new_relationships
@new_relationships ||= []
end
|
#post_save ⇒ Object
53
54
55
|
# File 'lib/n4j/node.rb', line 53
def post_save
clear_new_relationships!
end
|
#relationships(direction = 'all_relationships', types = [], clear_cache = false) ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/n4j/node.rb', line 57
def relationships(direction = 'all_relationships', types = [], clear_cache = false)
@relationship_cache ||= {}
if persisted?
path = from_neo4j_relative[direction] + '/' + [types].flatten.join('&')
@relationship_cache.delete(path) if clear_cache
@relationship_cache[path] ||= GenericRelationship.find_by_node_path(path)
else
[]
end
end
|
#traverse(opts = {}) ⇒ Object
72
73
74
75
76
|
# File 'lib/n4j/node.rb', line 72
def traverse(opts = {})
defaults = {:start => path, :instantiate_with => self.class }
N4j::Traversal.new(:start => path)
end
|