class Dry::Schema::KeyMap

@api public
Instances of this class are used as the very first step by the schema processors.
to rebuild an input hash using configured coercer function.
KeyMap objects expose an API for introspecting schema keys and the ability
Represents a list of keys defined by the DSL

def self.[](*keys)

Other tags:
    Api: - public

Returns:
  • (KeyMap) -
def self.[](*keys)
  new(keys)
end

def self.new(*args)

Returns:
  • (KeyMap) -

Parameters:
  • args (Array, Array, HashArray>) --
def self.new(*args)
  fetch_or_store(*args) { super }
end

def +(other)

Returns:
  • (KeyMap) -

Parameters:
  • other (KeyMap, Array) -- Either a key map or an array with key specs
def +(other)
  self.class.new(keys + other.to_a)
end

def coercible(&coercer)

Other tags:
    Api: - public

Returns:
  • (KeyMap) -
def coercible(&coercer)
  self.class.new(map { |key| key.coercible(&coercer) })
end

def dump

Returns:
  • (Array) -
def dump
  keys.map(&:dump)
end

def each(&)

Other tags:
    Api: - public
def each(&)
  keys.each(&)
end

def initialize(keys)

Other tags:
    Api: - private
def initialize(keys)
  @keys = keys.map { |key|
    case key
    when Hash
      root, rest = key.flatten
      Key::Hash[root, members: KeyMap[*rest]]
    when Array
      root, rest = key
      Key::Array[root, member: KeyMap[*rest]]
    when Key
      key
    else
      Key[key]
    end
  }
end

def inspect

Returns:
  • (String) -
def inspect
  "#<#{self.class}[#{keys.map(&:dump).map(&:inspect).join(", ")}]>"
end

def stringified

Other tags:
    Api: - public

Returns:
  • (KeyMap) -
def stringified
  self.class.new(map(&:stringified))
end

def to_dot_notation

Other tags:
    Api: - private
def to_dot_notation
  @to_dot_notation ||= map(&:to_dot_notation).flatten
end

def write(source, target = EMPTY_HASH.dup)

Other tags:
    Api: - public

Returns:
  • (Hash) -

Parameters:
  • target (Hash) -- The target hash
  • source (Hash) -- The source hash
def write(source, target = EMPTY_HASH.dup)
  each { |key| key.write(source, target) }
  target
end