Module: Neon::Relationship

Defined in:
lib/neon/relationship.rb,
lib/neon/relationship/rest.rb

Defined Under Namespace

Classes: Rest

Class Method Summary collapse

Class Method Details

.load(id, session = Session.current) ⇒ Relationship

Loads an existing relationship with the given id

Parameters:

  • id (Integer)

    The id of the relationship to be loaded and returned.

  • session (Session) (defaults to: Session.current)

    An optional session from where to load the node.

Returns:

  • (Relationship)

    An existing relationship with the given id and specified session. It returns nil if the node is not found.



24
25
26
27
28
29
30
# File 'lib/neon/relationship.rb', line 24

def load(id, session = Session.current)
  begin
    session.load_rel(id)
  rescue NoMethodError
    _raise_invalid_session_error(session)
  end
end

.new(start_node, name, end_node, attributes = {}) ⇒ Relationship

Creates a new Relationship and immediately persists it to the database. All subsequent changes are immediately persisted.

Parameters:

  • start_node (Node)

    The node from which the relationship starts i.e. is outgoing.

  • end_node (Node)

    The node at which the relationship ends i.e. is incoming.

  • attributes (Hash) (defaults to: {})

    An optional hash of properties to initialize the relationship with.

Returns:



12
13
14
# File 'lib/neon/relationship.rb', line 12

def new(start_node, name, end_node, attributes = {})
  start_node.create_rel_to(end_node, name, attributes)
end