Sha256: 76a69b1a5278afbbc745c0ee7b5692c84de560922fd0400bd0b0498e9431e19b

Contents?: true

Size: 493 Bytes

Versions: 2

Compression:

Stored size: 493 Bytes

Contents

module CypherBuilder
  def Node(prefix, labels: [])
    Node.new(prefix, labels: labels)
  end

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cypher_builder-0.0.5 lib/cypher_builder/node.rb
cypher_builder-0.0.4 lib/cypher_builder/node.rb