Sha256: 34427bd663a08f2ba9e25fd1af4a2c8c892162b8c6c7ceafac2d4c06f76070f8

Contents?: true

Size: 483 Bytes

Versions: 2

Compression:

Stored size: 483 Bytes

Contents

module CypherBuilder
  def Opt(*parts)
    Opt.new(*parts)
  end

  class Opt
    include Resolver

    def initialize(** params_and_parts)
      @params_and_parts = Hash[params_and_parts.map { |k, v| [k, wrap(v)] }]
    end

    def as_cypher(payload:)
      param, part = @params_and_parts.find { |k, _| payload.include?(k) }
      part = @params_and_parts.values.first unless part
      payload.already_used(param) if param

      resolve(part, payload: payload)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cypher_builder-0.0.2 lib/cypher_builder/opt.rb
cypher_builder-0.0.1 lib/cypher_builder/opt.rb