Class: Redgraph::Node
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#properties ⇒ Object
Returns the value of attribute properties.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(label: nil, properties: nil, id: nil, labels: nil) ⇒ Node
constructor
A new instance of Node.
- #label ⇒ Object
- #persisted? ⇒ Boolean
- #to_query_string(item_alias: 'node') ⇒ Object
Methods included from Util
#escape_value, #properties_to_string
Constructor Details
#initialize(label: nil, properties: nil, id: nil, labels: nil) ⇒ Node
Returns a new instance of Node.
9 10 11 12 13 14 |
# File 'lib/redgraph/node.rb', line 9 def initialize(label: nil, properties: nil, id: nil, labels: nil) @id = id raise(Error, "You can either define a single label or a label array") if label && labels @labels = labels || (label ? [label] : []) @properties = (properties || {}).with_indifferent_access end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/redgraph/node.rb', line 7 def id @id end |
#labels ⇒ Object
Returns the value of attribute labels.
7 8 9 |
# File 'lib/redgraph/node.rb', line 7 def labels @labels end |
#properties ⇒ Object
Returns the value of attribute properties.
7 8 9 |
# File 'lib/redgraph/node.rb', line 7 def properties @properties end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 |
# File 'lib/redgraph/node.rb', line 24 def ==(other) super || other.instance_of?(self.class) && !id.nil? && other.id == id end |
#label ⇒ Object
16 17 18 |
# File 'lib/redgraph/node.rb', line 16 def label labels.first end |
#persisted? ⇒ Boolean
20 21 22 |
# File 'lib/redgraph/node.rb', line 20 def persisted? id.present? end |
#to_query_string(item_alias: 'node') ⇒ Object
28 29 30 31 |
# File 'lib/redgraph/node.rb', line 28 def to_query_string(item_alias: 'node') _label = labels.map {|l| ":`#{l}`"}.join "(#{item_alias}#{_label} #{properties_to_string(properties)})" end |