Sha256: 1c69b48dad9ae6fa0495f7bf37aed2c10805d584d55f0aedd69e1378e19ab3c7

Contents?: true

Size: 320 Bytes

Versions: 5

Compression:

Stored size: 320 Bytes

Contents

# Converts value to hash recursively

module Dry
  class Struct
    module Hashify
      def self.[](value)
        if value.respond_to?(:to_hash)
          value.to_hash
        elsif value.respond_to?(:map)
          value.map { |item| self[item] }
        else
          value
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-struct-0.2.1 lib/dry/struct/hashify.rb
dry-struct-0.2.0 lib/dry/struct/hashify.rb
dry-struct-0.1.1 lib/dry/struct/hashify.rb
dry-struct-0.1.0 lib/dry/struct/hashify.rb
dry-struct-0.0.1 lib/dry/struct/hashify.rb