Class: Neo4j::Relationship
- Inherits:
-
Object
- Object
- Neo4j::Relationship
- Includes:
- EntityEquality, PropertyContainer, Wrapper
- Defined in:
- lib/neo4j/relationship.rb
Overview
A relationship between two nodes in the graph. A relationship has a start node, an end node and a type. You can attach properties to relationships like Neo4j::Node.
The fact that the relationship API gives meaning to start and end nodes implicitly means that all relationships have a direction. In the example above, rel would be directed from node to otherNode. A relationship's start node and end node and their relation to outgoing and incoming are defined so that the assertions in the following code are true:
Furthermore, Neo4j guarantees that a relationship is never “hanging freely,” i.e. start_node, end_node and other_node are guaranteed to always return valid, non-nil nodes.
Direct Known Subclasses
Defined Under Namespace
Modules: Wrapper
Constant Summary
Constant Summary
Constants included from PropertyValidator
PropertyValidator::VALID_PROPERTY_VALUE_CLASSES
Class Method Summary (collapse)
- + (Object) _load(neo_id, session = Neo4j::Session.current)
- + (Object) create(rel_type, from_node, other_node, props = {})
- + (Object) load(neo_id, session = Neo4j::Session.current)
Instance Method Summary (collapse)
-
- (Neo4j::Node) _end_node
Same as #end_node but does not wrap the node.
-
- (Object) _other_node(node)
Same as #other_node but can return a none wrapped node.
-
- (Neo4j::Node) _start_node
Same as #start_node but does not wrap the node.
- - (Object) del abstract
-
- (Neo4j::Node, Object) end_node
Returns the end node of this relationship.
-
- (true, false) exist?
abstract
If the relationship exists.
-
- (Object) get_property(key, value)
Directly get the property on the relationship (low level method, may need transaction).
-
- (Object) neo_id
abstract
The unique neo4j id.
-
- (Neo4j::Node) other_node(node)
A convenience operation that, given a node that is attached to this relationship, returns the other node.
-
- (Hash<Symbol,Object>) props
All properties of the relationship.
-
- (Object) props=(properties)
replace all properties with new properties.
-
- (Symbol) rel_type
Returns the relationship name.
-
- (Object) remove_property(key)
Directly remove the property on the relationship (low level method, may need transaction).
-
- (Object) set_property(key, value)
Directly set the property on the relationship (low level method, may need transaction).
-
- (Neo4j::Node, Object) start_node
Returns the start node of this relationship.
-
- (Object) update_props(properties)
Updates the properties, keeps old properties.
Methods included from Wrapper
Methods included from EntityEquality
Methods included from PropertyContainer
Methods included from PropertyValidator
#valid_property?, #validate_property
Class Method Details
+ (Object) _load(neo_id, session = Neo4j::Session.current)
155 156 157 |
# File 'lib/neo4j/relationship.rb', line 155 def _load(neo_id, session = Neo4j::Session.current) session.load_relationship(neo_id) end |
+ (Object) create(rel_type, from_node, other_node, props = {})
146 147 148 |
# File 'lib/neo4j/relationship.rb', line 146 def create(rel_type, from_node, other_node, props = {}) from_node.neo4j_obj.create_rel(rel_type, other_node, props) end |
+ (Object) load(neo_id, session = Neo4j::Session.current)
150 151 152 153 |
# File 'lib/neo4j/relationship.rb', line 150 def load(neo_id, session = Neo4j::Session.current) rel = _load(neo_id, session) rel && rel.wrapper end |
Instance Method Details
- (Neo4j::Node) _end_node
Same as #end_node but does not wrap the node
84 85 86 |
# File 'lib/neo4j/relationship.rb', line 84 def _end_node fail 'not implemented' end |
- (Object) _other_node(node)
Same as #other_node but can return a none wrapped node
134 135 136 137 138 139 140 141 142 |
# File 'lib/neo4j/relationship.rb', line 134 def _other_node(node) if node == _start_node _end_node elsif node == _end_node _start_node else fail "Node #{node.inspect} is neither start nor end node" end end |
- (Neo4j::Node) _start_node
Same as #start_node but does not wrap the node
72 73 74 |
# File 'lib/neo4j/relationship.rb', line 72 def _start_node fail 'not implemented' end |
- (Object) del
89 90 91 |
# File 'lib/neo4j/relationship.rb', line 89 def del fail 'not implemented' end |
- (Neo4j::Node, Object) end_node
Returns the end node of this relationship.
78 79 80 |
# File 'lib/neo4j/relationship.rb', line 78 def end_node _end_node.wrapper end |
- (true, false) exist?
Returns if the relationship exists
101 102 103 |
# File 'lib/neo4j/relationship.rb', line 101 def exist? fail 'not implemented' end |
- (Object) get_property(key, value)
Directly get the property on the relationship (low level method, may need transaction)
60 61 62 |
# File 'lib/neo4j/relationship.rb', line 60 def get_property(key, value) fail 'not implemented' end |
- (Object) neo_id
The unique neo4j id
95 96 97 |
# File 'lib/neo4j/relationship.rb', line 95 def neo_id fail 'not implemented' end |
- (Neo4j::Node) other_node(node)
A convenience operation that, given a node that is attached to this relationship, returns the other node. For example if node is a start node, the end node will be returned, and vice versa. This is a very convenient operation when you're manually traversing the node space by invoking one of the #rels method on a node. For example, to get the node “at the other end” of a relationship, use the following:
129 130 131 |
# File 'lib/neo4j/relationship.rb', line 129 def other_node(node) _other_node(node.neo4j_obj).wrapper end |
- (Hash<Symbol,Object>) props
Returns all properties of the relationship
29 30 31 |
# File 'lib/neo4j/relationship.rb', line 29 def props fail 'not implemented' end |
- (Object) props=(properties)
replace all properties with new properties
35 36 37 |
# File 'lib/neo4j/relationship.rb', line 35 def props=(properties) fail 'not implemented' end |
- (Symbol) rel_type
Returns the relationship name
112 113 114 |
# File 'lib/neo4j/relationship.rb', line 112 def rel_type fail 'not implemented' end |
- (Object) remove_property(key)
Directly remove the property on the relationship (low level method, may need transaction)
46 47 48 |
# File 'lib/neo4j/relationship.rb', line 46 def remove_property(key) fail 'not implemented' end |
- (Object) set_property(key, value)
Directly set the property on the relationship (low level method, may need transaction)
53 54 55 |
# File 'lib/neo4j/relationship.rb', line 53 def set_property(key, value) fail 'not implemented' end |
- (Neo4j::Node, Object) start_node
Returns the start node of this relationship.
66 67 68 |
# File 'lib/neo4j/relationship.rb', line 66 def start_node _start_node.wrapper end |
- (Object) update_props(properties)
Updates the properties, keeps old properties
41 42 43 |
# File 'lib/neo4j/relationship.rb', line 41 def update_props(properties) fail 'not implemented' end |