Sha256: c1eb1b13dbd13bdb236247befe31a1d970fee8e400e53056d99f2efdcc644aa9

Contents?: true

Size: 236 Bytes

Versions: 3

Compression:

Stored size: 236 Bytes

Contents

class Hash
  # Deletes all key/value pairs where the value is empty string/array/hash or nil. 
  def delete_blank
    delete_if do |k, v|
      (v.blank? && v != false) or v.instance_of?(Hash) && v.delete_blank.empty?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
inactive_support-1.0.0 lib/inactive_support/hash/delete_blank.rb
inactive_support-0.1.0 lib/inactive_support/hash/delete_blank.rb
inactive_support-0.0.1 lib/inactive_support/core_ext/hash.rb