Sha256: 918ace9b320ff11b7f805ae415ebcb3aa740e4fa815b4d9996fb88efb8ad3489
Contents?: true
Size: 716 Bytes
Versions: 24
Compression:
Stored size: 716 Bytes
Contents
module Ufo::Utils class Squeezer def initialize(data) @data = data end def squeeze(new_data=nil) data = new_data.nil? ? @data : new_data case data when Array # .compact prevents infinite loop when data = [nil] on accident # IE: config.elb.ssl.certificates = acm_cert("domain.not.found") data.compact.map! { |v| squeeze(v) } when Hash data.each_with_object({}) do |(k,v), squeezed| # only remove nil and empty Array values within Hash structures squeezed[k] = squeeze(v) unless v.nil? # || v.is_a?(Array) && v.empty? squeezed end else data # do not transform end end end end
Version data entries
24 entries across 24 versions & 1 rubygems