Class: Neo4j::Driver::Types::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/driver/types/relationship.rb

Overview

Represents a Relationship in the Neo4j graph. Mirrors Java's org.neo4j.driver.types.Relationship.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, start_node_id, end_node_id, type, properties, element_id = nil, start_node_element_id = nil, end_node_element_id = nil) ⇒ Relationship

Bolt 4.x wire doesn't include start/end_node_element_id — PackStream hydration passes nil for those slots. Fall back to the stringified node id so callers always see a value (matches what Java's driver does for 4.x). Path-bound relationships pass the actual node element_ids from #bind, which override the fallback.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/neo4j/driver/types/relationship.rb', line 18

def initialize(id, start_node_id, end_node_id, type, properties,
               element_id = nil, start_node_element_id = nil,
               end_node_element_id = nil)
  @id = id
  @start_node_id = start_node_id
  @end_node_id = end_node_id
  @type = type
  @properties = properties
  @element_id = element_id || id.to_s
  @start_node_element_id = start_node_element_id || start_node_id.to_s
  @end_node_element_id = end_node_element_id || end_node_id.to_s
end

Instance Attribute Details

#element_idObject (readonly)

Returns the value of attribute element_id.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def element_id
  @element_id
end

#end_node_element_idObject (readonly)

Returns the value of attribute end_node_element_id.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def end_node_element_id
  @end_node_element_id
end

#end_node_idObject (readonly)

Returns the value of attribute end_node_id.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def end_node_id
  @end_node_id
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def id
  @id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def properties
  @properties
end

#start_node_element_idObject (readonly)

Returns the value of attribute start_node_element_id.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def start_node_element_id
  @start_node_element_id
end

#start_node_idObject (readonly)

Returns the value of attribute start_node_id.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def start_node_id
  @start_node_id
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/neo4j/driver/types/relationship.rb', line 9

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
# File 'lib/neo4j/driver/types/relationship.rb', line 35

def ==(other)
  other.is_a?(Relationship) && other.id == @id
end

#[](key) ⇒ Object



31
32
33
# File 'lib/neo4j/driver/types/relationship.rb', line 31

def [](key)
  @properties[key.to_s] || @properties[key.to_sym]
end