module Neo4j::RelationshipMixin

Use this mixin to wrap Neo4j Relationship Java object. This mixin is similar to Neo4j::NodeMixin which wraps Neo4j::Node Java objects.

Instance Methods, Mixins

*

Class Methods, Mixins

Public Instance Methods

_java_entity() click to toggle source
# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 62
def _java_entity
  @_java_rel
end
_java_rel() click to toggle source

Returns the org.neo4j.graphdb.Relationship wrapped object

# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 58
def _java_rel
  @_java_rel
end
del() click to toggle source

Deletes this relationship

# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 79
def del
  delete
end
end_node() click to toggle source

Returns the end node of this relationship

# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 67
def end_node
  id = getEndNode.getId
  Neo4j::Node.load(id)
end
exist?() click to toggle source
# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 83
def exist?
  Neo4j::Relationship.exist?(self)
end
other_node(node) click to toggle source

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 operations on node.

This operation will throw a runtime exception if node is neither this relationship’s start node nor its end node.

Example

For example, to get the node “at the other end” of a relationship, use the following:

Node endNode = node.rel(:some_rel_type).other_node(node)
# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 97
def other_node(node)
  neo_node = node.respond_to?(:_java_node)? node._java_node : node
  id = getOtherNode(neo_node).getId
  Neo4j::Node.load(id)
end
relationship_type() click to toggle source

Returns the neo relationship type that this relationship is used in. (see java API org.neo4j.graphdb.Relationship#getType and org.neo4j.graphdb.RelationshipType)

Returns

the relationship type (of type Symbol)

# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 110
def relationship_type
  @_java_rel.getType.name.to_sym
end
start_node() click to toggle source

Returns the start node of this relationship

# File lib/neo4j/relationship_mixin/relationship_mixin.rb, line 73
def start_node
  id = getStartNode.getId
  Neo4j::Node.load(id)
end