Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ext/core_ext.rb
Instance Method Summary collapse
Instance Method Details
#assert_has_keys(*valid_keys) ⇒ Object
26 27 28 29 |
# File 'lib/ext/core_ext.rb', line 26 def assert_has_keys(*valid_keys) missing_keys = [valid_keys].flatten - keys raise(ArgumentError, "Missing Option(s): #{missing_keys.join(", ")}") unless missing_keys.empty? end |
#symbolize_keys ⇒ Object
15 16 17 18 19 20 |
# File 'lib/ext/core_ext.rb', line 15 def symbolize_keys inject({}) do |, (key, value)| [(key.to_sym rescue key) || key] = value end end |
#symbolize_keys! ⇒ Object
22 23 24 |
# File 'lib/ext/core_ext.rb', line 22 def symbolize_keys! self.replace(self.symbolize_keys) end |