Sha256: 8a9b14a0b6126bf9d07f81810aedfa9424c1e7cc42e09c0355701d1b9511dfde
Contents?: true
Size: 1009 Bytes
Versions: 3
Compression:
Stored size: 1009 Bytes
Contents
module Koine module Attributes module Adapter class HashOf < Base def initialize(key_adapter, value_adapter) @key_adapter = key_adapter || raise(ArgumentError, 'Invalid key adapter') @value_adapter = value_adapter || raise(ArgumentError, 'Invalid value adapter') with_default_value({}) end def for_keys @key_adapter end def for_values @value_adapter end def with_attribute_name(name) @key_adapter.with_attribute_name(name) @value_adapter.with_attribute_name(name) super(name) end private def coerce_not_nil(hash) secure do {}.tap do |new_hash| hash.each do |key, value| key = @key_adapter.coerce(key) value = @value_adapter.coerce(value) new_hash[key] = value end end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems