Class: Redgraph::Node

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/redgraph/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#escape_value, #properties_to_string

Constructor Details

#initialize(label: nil, properties: nil, id: nil) ⇒ Node

Returns a new instance of Node.



9
10
11
12
13
# File 'lib/redgraph/node.rb', line 9

def initialize(label: nil, properties: nil, id: nil)
  @id = id
  @label = label
  @properties = (properties || {}).with_indifferent_access
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/redgraph/node.rb', line 7

def id
  @id
end

#labelObject

Returns the value of attribute label.



7
8
9
# File 'lib/redgraph/node.rb', line 7

def label
  @label
end

#propertiesObject

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



19
20
21
# File 'lib/redgraph/node.rb', line 19

def ==(other)
  super || other.instance_of?(self.class) && !id.nil? && other.id == id
end

#persisted?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/redgraph/node.rb', line 15

def persisted?
  id.present?
end

#to_query_string(item_alias: 'node') ⇒ Object



23
24
25
26
# File 'lib/redgraph/node.rb', line 23

def to_query_string(item_alias: 'node')
  _label = ":#{label}" if label
  "(#{item_alias}#{_label} #{properties_to_string(properties)})"
end