Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/support/extensions.rb
Instance Method Summary collapse
- #compact ⇒ Object
- #compact! ⇒ Object
-
#stringify_keys ⇒ Object
Taken from Rails, with appreciation to DHH.
Instance Method Details
#compact ⇒ Object
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_keys ⇒ Object
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 |, (key, value)| [key.to_s] = value end end |