Module: HashSqueezer

Extended by:
HashSqueezer
Included in:
HashSqueezer
Defined in:
lib/hash_squeezer.rb,
lib/hash_squeezer/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Instance Method Details

#squeeze(hash_or_array) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/hash_squeezer.rb', line 5

def squeeze(hash_or_array)
  p = proc do |*args|
    v = args.last
    v.delete_if(&p) if v.respond_to? :delete_if
    v.nil? || (v != '' && v.respond_to?(:"empty?") && v.empty?)
  end

  hash_or_array.delete_if(&p)
end