Sha256: 2ffabe2ffc3ebabc10b02d7336b583e50b47f9c7b31dbde1dd21f62e61286319
Contents?: true
Size: 588 Bytes
Versions: 7
Compression:
Stored size: 588 Bytes
Contents
class Lono::Template::Strategy::Dsl::Builder class Squeezer def initialize(data) @data = data end def squeeze(new_data=nil) data = new_data.nil? ? @data : new_data case data when Array data.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
7 entries across 7 versions & 1 rubygems