Sha256: 9575aa45613a3726cdb862551892d11743405c7339ac5d5ebe128a007a11c944

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 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

        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

Version Path
koine-attributes-0.3.2 lib/koine/attributes/adapter/hash_of.rb
koine-attributes-0.3.1 lib/koine/attributes/adapter/hash_of.rb
koine-attributes-0.3.0 lib/koine/attributes/adapter/hash_of.rb