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

Version Path
ufo-6.3.13 lib/ufo/utils/squeezer.rb
ufo-6.3.12 lib/ufo/utils/squeezer.rb
ufo-6.3.11 lib/ufo/utils/squeezer.rb
ufo-6.3.10 lib/ufo/utils/squeezer.rb
ufo-6.3.9 lib/ufo/utils/squeezer.rb
ufo-6.3.8 lib/ufo/utils/squeezer.rb
ufo-6.3.7 lib/ufo/utils/squeezer.rb
ufo-6.3.6 lib/ufo/utils/squeezer.rb
ufo-6.3.5 lib/ufo/utils/squeezer.rb
ufo-6.3.4 lib/ufo/utils/squeezer.rb
ufo-6.3.3 lib/ufo/utils/squeezer.rb
ufo-6.3.2 lib/ufo/utils/squeezer.rb
ufo-6.3.1 lib/ufo/utils/squeezer.rb
ufo-6.3.0 lib/ufo/utils/squeezer.rb
ufo-6.2.5 lib/ufo/utils/squeezer.rb
ufo-6.2.4 lib/ufo/utils/squeezer.rb
ufo-6.2.3 lib/ufo/utils/squeezer.rb
ufo-6.2.2 lib/ufo/utils/squeezer.rb
ufo-6.2.1 lib/ufo/utils/squeezer.rb
ufo-6.2.0 lib/ufo/utils/squeezer.rb