class Dry::Schema::Key::Hash
A specialized key type which handles nested hashes
@api private
Attributes
members[R]
@api private
Public Class Methods
new(id, members:, **opts)
click to toggle source
@api private
Calls superclass method
# File lib/dry/schema/key.rb, line 99 def initialize(id, members:, **opts) super(id, **opts) @members = members end
Public Instance Methods
coercible(&coercer)
click to toggle source
@api private
# File lib/dry/schema/key.rb, line 116 def coercible(&coercer) new(coercer: coercer, members: members.coercible(&coercer)) end
dump()
click to toggle source
@api private
# File lib/dry/schema/key.rb, line 131 def dump {name => members.map(&:dump)} end
read(source)
click to toggle source
@api private
Calls superclass method
# File lib/dry/schema/key.rb, line 105 def read(source) super if source.is_a?(::Hash) end
stringified()
click to toggle source
@api private
# File lib/dry/schema/key.rb, line 121 def stringified new(name: name.to_s, members: members.stringified) end
to_dot_notation()
click to toggle source
@api private
# File lib/dry/schema/key.rb, line 126 def to_dot_notation [name].product(members.flat_map(&:to_dot_notation)).map { |e| e.join(DOT) } end
write(source, target)
click to toggle source
# File lib/dry/schema/key.rb, line 109 def write(source, target) read(source) { |value| target[coerced_name] = value.is_a?(::Hash) ? members.write(value) : value } end