Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/support/extensions.rb

Instance Method Summary collapse

Instance Method Details

#compactObject



18
19
20
# File 'lib/support/extensions.rb', line 18

def compact
  reject { |key, val| val.nil? }
end

#compact!Object



22
23
24
# File 'lib/support/extensions.rb', line 22

def compact!
  delete_if { |key, val| val.nil? }
end

#stringify_keysObject

Taken from Rails, with appreciation to DHH



11
12
13
14
15
16
# File 'lib/support/extensions.rb', line 11

def stringify_keys
  inject({}) do |options, (key, value)|
    options[key.to_s] = value
    options
  end
end