Sha256: b75a3fb9906cb9c02fcd3512421055c56a76df4fa6ccf75ef0de312ad059bdc3

Contents?: true

Size: 392 Bytes

Versions: 5

Compression:

Stored size: 392 Bytes

Contents

module Compel
  module Coercion

    class Hash < Type

      def coerce_value
        if ::Hash.try_convert(value)
          symbolyze_keys(value)
        end
      end

      private

      def symbolyze_keys(hash)
        {}.tap do |symbolyzed_hash|
          hash.each do |key, value|
            symbolyzed_hash[key.to_sym] = value
          end
        end
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
compel-0.5.1 lib/compel/coercion/types/hash.rb
compel-0.5.0 lib/compel/coercion/types/hash.rb
compel-0.4.3 lib/compel/coercion/types/hash.rb
compel-0.4.2 lib/compel/coercion/types/hash.rb
compel-0.4.0 lib/compel/coercion/types/hash.rb