Sha256: d016920658b0f765445beeddfb4cfce4c706d43d6106aa3cb4eafcfe75637dfe
Contents?: true
Size: 460 Bytes
Versions: 2
Compression:
Stored size: 460 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 elsif value.respond_to?(:to_ary) value.to_ary.map { |item| self[item] } else value end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-struct-0.5.1 | lib/dry/struct/hashify.rb |
dry-struct-0.5.0 | lib/dry/struct/hashify.rb |