Sha256: 670df89bba651ab4a1500f7ce45117e8032ff62c46ba9118fd85c598934f0b32
Contents?: true
Size: 585 Bytes
Versions: 2
Compression:
Stored size: 585 Bytes
Contents
module ReplayApi module CompactAttributes def compact_attributes compact(attributes) end private def compact(input) input.each_with_object({}) do |(key, value), hash| next if value.nil? if value.is_a? Hash new_value = compact(value) next if new_value.empty? hash[key] = new_value elsif value.is_a? Model new_value = value.compact_attributes next if new_value.empty? hash[key] = new_value else hash[key] = value end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
replay_api-0.0.5 | lib/replay_api/compact_attributes.rb |
replay_api-0.0.3 | lib/replay_api/compact_attributes.rb |