Class: Dry::Types::Hash::Symbolized
- Inherits:
-
Weak
- Object
- Definition
- Dry::Types::Hash
- Schema
- Weak
- Dry::Types::Hash::Symbolized
- Defined in:
- lib/dry/types/hash/schema.rb
Instance Attribute Summary
Attributes inherited from Schema
Attributes inherited from Definition
Attributes included from Options
Instance Method Summary collapse
- #call(hash, meth = :call) ⇒ Object (also: #[])
Methods inherited from Weak
Methods inherited from Schema
Methods inherited from Dry::Types::Hash
#schema, #strict, #symbolized, #weak
Methods inherited from Definition
[], #default?, #failure, #initialize, #maybe?, #name, #primitive?, #result, #success, #try
Methods included from Builder
#constrained, #constrained_type, #constructor, #default, #enum, #maybe, #optional, #safe, #|
Methods included from Options
Constructor Details
This class inherits a constructor from Dry::Types::Hash::Schema
Instance Method Details
#call(hash, meth = :call) ⇒ Object Also known as: []
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/dry/types/hash/schema.rb', line 82 def call(hash, meth = :call) member_types.each_with_object({}) do |(key, type), result| if hash.key?(key) result[key] = type.__send__(meth, hash[key]) else key_name = key.to_s if hash.key?(key_name) result[key] = type.__send__(meth, hash[key_name]) else resolve_missing_value(result, key, type) end end end end |