Class: Neon::Relationship::Rest

Inherits:
Object
  • Object
show all
Includes:
PropertyContainer::Rest
Defined in:
lib/neon/relationship/rest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PropertyContainer::Rest

#==, #[], #[]=, #del, #destroy, #props, #props=

Methods included from TransactionHelpers::Rest

#run_rest_transaction

Constructor Details

#initialize(relationship, session) ⇒ Rest

Returns a new instance of Rest.



9
10
11
12
13
14
15
16
17
# File 'lib/neon/relationship/rest.rb', line 9

def initialize(relationship, session)
  @relationship = relationship
  @session = session
  @id = @relationship["self"].split('/').last.to_i # Set the id
  @start = @session.load(@relationship["start"])
  @end = @session.load(@relationship["end"])
  @nodes = [@start, @end]
  @type  = @relationship["type"]
end

Instance Attribute Details

#endObject (readonly)

Returns the value of attribute end.



7
8
9
# File 'lib/neon/relationship/rest.rb', line 7

def end
  @end
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/neon/relationship/rest.rb', line 7

def id
  @id
end

#nodesObject (readonly)

Returns the value of attribute nodes.



7
8
9
# File 'lib/neon/relationship/rest.rb', line 7

def nodes
  @nodes
end

#sessionObject (readonly)

Returns the value of attribute session.



7
8
9
# File 'lib/neon/relationship/rest.rb', line 7

def session
  @session
end

#startObject (readonly)

Returns the value of attribute start.



7
8
9
# File 'lib/neon/relationship/rest.rb', line 7

def start
  @start
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/neon/relationship/rest.rb', line 7

def type
  @type
end

Instance Method Details

#other_node(node) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/neon/relationship/rest.rb', line 19

def other_node(node)
 case node
 when @start
   @end
 when @end
   @start
 else
   nil
 end
      rescue NoMethodError => e
 _raise_doesnt_exist_anymore_error(e)
end

#to_sObject



33
34
35
# File 'lib/neon/relationship/rest.rb', line 33

def to_s
  "REST Relationship[#{@id}]"
end