Sha256: 08f7600a21b394174c315c7590365aaf3bc7e77a454d02b81725035d96b2d83b

Contents?: true

Size: 521 Bytes

Versions: 3

Compression:

Stored size: 521 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:, context:)
      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, context: context.add(self))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cypher_builder-0.0.5 lib/cypher_builder/opt.rb
cypher_builder-0.0.4 lib/cypher_builder/opt.rb
cypher_builder-0.0.3 lib/cypher_builder/opt.rb