Class: Neography::Relationship
Instance Attribute Summary collapse
#neo_id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Index
find, index
Methods included from Property
#[], #[]=, method_missing, #new_ostruct_member
Methods included from Equal
#==, #eql?, #equal?
Constructor Details
#initialize(hash = nil, server = nil) ⇒ Relationship
Returns a new instance of Relationship.
35
36
37
38
39
40
41
|
# File 'lib/neography/relationship.rb', line 35
def initialize(hash=nil, server=nil)
super(hash)
@start_node = hash["start"].split('/').last
@end_node = hash["end"].split('/').last
@rel_type = hash["type"]
neo_server = server
end
|
Instance Attribute Details
#end_node ⇒ Object
Returns the value of attribute end_node.
7
8
9
|
# File 'lib/neography/relationship.rb', line 7
def end_node
@end_node
end
|
#rel_type ⇒ Object
Returns the value of attribute rel_type.
7
8
9
|
# File 'lib/neography/relationship.rb', line 7
def rel_type
@rel_type
end
|
#start_node ⇒ Object
Returns the value of attribute start_node.
7
8
9
|
# File 'lib/neography/relationship.rb', line 7
def start_node
@start_node
end
|
Class Method Details
.create(type, from_node, to_node, props = nil) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/neography/relationship.rb', line 11
def create(type, from_node, to_node, props=nil)
rel = Neography::Relationship.new(from_node.neo_server.create_relationship(type, from_node, to_node, props))
rel.start_node = from_node
rel.end_node = to_node
rel.rel_type = type
rel
end
|
Instance Method Details
#del ⇒ Object
51
52
53
|
# File 'lib/neography/relationship.rb', line 51
def del
self.start_node.neo_server.delete_relationship(self.neo_id)
end
|
#exist? ⇒ Boolean
55
56
57
|
# File 'lib/neography/relationship.rb', line 55
def exist?
!self.start_node.neo_server.get_relationship(self.neo_id).nil?
end
|
#neo_server ⇒ Object
43
44
45
|
# File 'lib/neography/relationship.rb', line 43
def neo_server
@neo_server ||= self.start_node.neo_server
end
|
#neo_server=(server) ⇒ Object
47
48
49
|
# File 'lib/neography/relationship.rb', line 47
def neo_server=(server)
@neo_server = server
end
|
#other_node(node) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/neography/relationship.rb', line 59
def other_node(node)
if node == @start_node
@end_node
else
@start_node
end
end
|