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
Overview
Symbolized hash will turn string key names into symbols.
Instance Attribute Summary
Attributes inherited from Schema
Attributes inherited from Definition
Attributes included from Options
Instance Method Summary collapse
- #resolve(hash) ⇒ Object private
Methods inherited from Weak
Methods inherited from Schema
#call, #coerce, #initialize, #resolve_missing_value, #try, #try_coerce
Methods included from MaybeTypes
Methods inherited from Dry::Types::Hash
#permissive, #resolve_missing_value, #schema, #strict, #strict_with_defaults, #symbolized, #weak
Methods inherited from Definition
[], #call, #constrained?, #default?, #failure, #initialize, #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
#resolve(hash) ⇒ Object (private)
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/dry/types/hash/schema.rb', line 206 def resolve(hash) result = {} member_types.each do |key, type| keyname = if hash.key?(key) key elsif hash.key?(string_key = key.to_s) string_key end if keyname result[key] = yield(type, key, hash[keyname]) else resolve_missing_value(result, key, type) end end result end |