Class: Neo4j::Driver::Types::Entity
- Inherits:
-
Object
- Object
- Neo4j::Driver::Types::Entity
- Defined in:
- lib/neo4j/driver/types/entity.rb
Overview
Base for graph entities — a Node or a Relationship. Holds the shared identity (id / element_id) and property map, mirroring org.neo4j.driver.types.Entity, which the JRuby flavour exposes as Types::Entity. Kept as a real superclass (not just to de-duplicate Node/Relationship) because downstream gems and applications type-check against Neo4j::Driver::Types::Entity.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#element_id ⇒ Object
readonly
Returns the value of attribute element_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Entities compare by identity within their own type (a Node is never equal to a Relationship), matching the Java driver.
-
#[](key) ⇒ Object
Property lookup.
- #hash ⇒ Object
-
#initialize(id, properties, element_id = nil) ⇒ Entity
constructor
element_id defaults to the stringified id — the Bolt 4.x wire carries no element_id, and callers always expect a value (matches Java).
Constructor Details
#initialize(id, properties, element_id = nil) ⇒ Entity
element_id defaults to the stringified id — the Bolt 4.x wire carries no element_id, and callers always expect a value (matches Java).
17 18 19 20 21 |
# File 'lib/neo4j/driver/types/entity.rb', line 17 def initialize(id, properties, element_id = nil) @id = id @properties = properties @element_id = element_id || id.to_s end |
Instance Attribute Details
#element_id ⇒ Object (readonly)
Returns the value of attribute element_id.
13 14 15 |
# File 'lib/neo4j/driver/types/entity.rb', line 13 def element_id @element_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/neo4j/driver/types/entity.rb', line 13 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
13 14 15 |
# File 'lib/neo4j/driver/types/entity.rb', line 13 def properties @properties end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Entities compare by identity within their own type (a Node is never equal to a Relationship), matching the Java driver. eql?/hash track
so entities work as Hash/Set keys.
31 32 33 |
# File 'lib/neo4j/driver/types/entity.rb', line 31 def ==(other) other.is_a?(self.class) && other.id == @id end |
#[](key) ⇒ Object
Property lookup. PackStream hydration symbolizes every map key (Unpacker#unpack_map), so properties are symbol-keyed. Coerce the key so a string caller works too — the Java flavour accepts strings.
26 |
# File 'lib/neo4j/driver/types/entity.rb', line 26 def [](key) = @properties[key.to_sym] |
#hash ⇒ Object
36 |
# File 'lib/neo4j/driver/types/entity.rb', line 36 def hash = @id.hash |