Class: VagrantPlugins::VagrantLibvirt::Util::HashWithCompactBlank

Inherits:
Vagrant::Util::HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/vagrant-libvirt/util/hash_with_blank_filter.rb

Instance Method Summary collapse

Instance Method Details

#compact_blankObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vagrant-libvirt/util/hash_with_blank_filter.rb', line 7

def compact_blank
  copy = self.dup
  copy.each do |k, _v|
    if copy[k].respond_to(:compact_blank)
      copy[k].compact_blank
    elsif copy[k].respond_to(:each_pair)
      copy[k].delete_if { |_k, v| v.to_s.empty? }
    else
      copy[k].reject! { |e| e.to_s.empty? }
    end
  end.delete_if { |_k, v| v.empty? }
end