Class: Neo4j::Relationship
- Inherits:
-
Object
- Object
- Neo4j::Relationship
- Includes:
- EntityEquality, EntityMarshal, 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
Constants included from PropertyValidator
PropertyValidator::VALID_PROPERTY_VALUE_CLASSES
Class Method Summary collapse
- ._load(neo_id, session = Neo4j::Session.current) ⇒ Object
- .create(rel_type, from_node, other_node, props = {}) ⇒ Object
- .load(neo_id, session = Neo4j::Session.current) ⇒ Object
Instance Method Summary collapse
-
#_end_node ⇒ Neo4j::Node
Same as #end_node but does not wrap the node.
-
#_other_node(node) ⇒ Object
Same as #other_node but can return a none wrapped node.
-
#_start_node ⇒ Neo4j::Node
Same as #start_node but does not wrap the node.
- #del ⇒ Object abstract
-
#end_node ⇒ Neo4j::Node, Object
Returns the end node of this relationship.
-
#exist? ⇒ true, false
abstract
If the relationship exists.
-
#get_property(key, value) ⇒ Object
Directly get the property on the relationship (low level method, may need transaction).
-
#neo_id ⇒ Object
abstract
The unique neo4j id.
-
#other_node(node) ⇒ Neo4j::Node
A convenience operation that, given a node that is attached to this relationship, returns the other node.
-
#props ⇒ Hash<Symbol,Object>
All properties of the relationship.
-
#props=(properties) ⇒ Object
replace all properties with new properties.
-
#rel_type ⇒ Symbol
Returns the relationship name.
-
#remove_property(key) ⇒ Object
Directly remove the property on the relationship (low level method, may need transaction).
-
#set_property(key, value) ⇒ Object
Directly set the property on the relationship (low level method, may need transaction).
-
#start_node ⇒ Neo4j::Node, Object
Returns the start node of this relationship.
-
#update_props(properties) ⇒ Object
Updates the properties, keeps old properties.
Methods included from EntityMarshal
Methods included from Wrapper
Methods included from EntityEquality
Methods included from PropertyContainer
Methods included from PropertyValidator
#valid_property?, #validate_property!
Class Method Details
._load(neo_id, session = Neo4j::Session.current) ⇒ Object
156 157 158 |
# File 'lib/neo4j/relationship.rb', line 156 def _load(neo_id, session = Neo4j::Session.current) session.load_relationship(neo_id) end |
.create(rel_type, from_node, other_node, props = {}) ⇒ Object
147 148 149 |
# File 'lib/neo4j/relationship.rb', line 147 def create(rel_type, from_node, other_node, props = {}) from_node.neo4j_obj.create_rel(rel_type, other_node, props) end |
Instance Method Details
#_end_node ⇒ Neo4j::Node
Same as #end_node but does not wrap the node
85 86 87 |
# File 'lib/neo4j/relationship.rb', line 85 def _end_node fail 'not implemented' end |
#_other_node(node) ⇒ Object
Same as #other_node but can return a none wrapped node
135 136 137 138 139 140 141 142 143 |
# File 'lib/neo4j/relationship.rb', line 135 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 |
#_start_node ⇒ Neo4j::Node
Same as #start_node but does not wrap the node
73 74 75 |
# File 'lib/neo4j/relationship.rb', line 73 def _start_node fail 'not implemented' end |
#del ⇒ Object
90 91 92 |
# File 'lib/neo4j/relationship.rb', line 90 def del fail 'not implemented' end |
#end_node ⇒ Neo4j::Node, Object
Returns the end node of this relationship.
79 80 81 |
# File 'lib/neo4j/relationship.rb', line 79 def end_node _end_node.wrapper end |
#exist? ⇒ true, false
Returns if the relationship exists.
102 103 104 |
# File 'lib/neo4j/relationship.rb', line 102 def exist? fail 'not implemented' end |
#get_property(key, value) ⇒ Object
Directly get the property on the relationship (low level method, may need transaction)
61 62 63 |
# File 'lib/neo4j/relationship.rb', line 61 def get_property(key, value) fail 'not implemented' end |
#neo_id ⇒ Object
The unique neo4j id
96 97 98 |
# File 'lib/neo4j/relationship.rb', line 96 def neo_id fail 'not implemented' end |
#other_node(node) ⇒ Neo4j::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:
130 131 132 |
# File 'lib/neo4j/relationship.rb', line 130 def other_node(node) _other_node(node.neo4j_obj).wrapper end |
#props ⇒ Hash<Symbol,Object>
Returns all properties of the relationship.
30 31 32 |
# File 'lib/neo4j/relationship.rb', line 30 def props fail 'not implemented' end |
#props=(properties) ⇒ Object
replace all properties with new properties
36 37 38 |
# File 'lib/neo4j/relationship.rb', line 36 def props=(properties) fail 'not implemented' end |
#rel_type ⇒ Symbol
Returns the relationship name
113 114 115 |
# File 'lib/neo4j/relationship.rb', line 113 def rel_type fail 'not implemented' end |
#remove_property(key) ⇒ Object
Directly remove the property on the relationship (low level method, may need transaction)
47 48 49 |
# File 'lib/neo4j/relationship.rb', line 47 def remove_property(key) fail 'not implemented' end |
#set_property(key, value) ⇒ Object
Directly set the property on the relationship (low level method, may need transaction)
54 55 56 |
# File 'lib/neo4j/relationship.rb', line 54 def set_property(key, value) fail 'not implemented' end |
#start_node ⇒ Neo4j::Node, Object
Returns the start node of this relationship.
67 68 69 |
# File 'lib/neo4j/relationship.rb', line 67 def start_node _start_node.wrapper end |
#update_props(properties) ⇒ Object
Updates the properties, keeps old properties
42 43 44 |
# File 'lib/neo4j/relationship.rb', line 42 def update_props(properties) fail 'not implemented' end |