Sha256: bd190736c5e62937695f4ed57b7dbcd12effe6713f8b98bfd8c3d77b393bec1f
Contents?: true
Size: 836 Bytes
Versions: 4
Compression:
Stored size: 836 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 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
4 entries across 4 versions & 1 rubygems