Method: Dry::Schema::KeyMap#initialize

Defined in:
lib/dry/schema/key_map.rb

#initialize(keys) ⇒ KeyMap

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set key objects



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/dry/schema/key_map.rb', line 52

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