Class: CypherBuilder::Node

Inherits:
BasicObject
Defined in:
lib/cypher_builder/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix, labels: []) ⇒ Node

Returns a new instance of Node.



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

def initialize(prefix, labels: [])
  @prefix, @labels = prefix, ::Kernel.Array(labels)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *_) ⇒ Object



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

def method_missing(name, *_)
  Field.new(@prefix, name)
end

Instance Method Details

#as_cypher(_ = nil) ⇒ Object



11
12
13
# File 'lib/cypher_builder/node.rb', line 11

def as_cypher(_ = nil)
  ::Kernel.sprintf('(%s)', [@prefix, *@labels].compact.join(':'))
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to_missing?(name, include_private = false)
  true
end