Sha256: 2b0bb338b43bdc6cd9405df394304215e857c7ce778d621101505876f394039b
Contents?: true
Size: 505 Bytes
Versions: 3
Compression:
Stored size: 505 Bytes
Contents
module Dry class Struct # Helper for {Struct#to_hash} implementation module Hashify # Converts value to hash recursively # @param [#to_hash, #map, Object] value # @return [Hash, Array] def self.[](value) if value.respond_to?(:to_hash) value.to_hash.transform_values { |current| self[current] } elsif value.respond_to?(:to_ary) value.to_ary.map { |item| self[item] } else value end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-struct-1.2.0 | lib/dry/struct/hashify.rb |
dry-struct-1.1.1 | lib/dry/struct/hashify.rb |
dry-struct-1.1.0 | lib/dry/struct/hashify.rb |