Module: Propono::Utils
- Defined in:
- lib/propono/utils.rb
Class Method Summary collapse
-
.symbolize_keys(hash) ⇒ Object
Returns
hash
with all primary and nested keys to string values symbolised To avoid conflicts with ActiveSupport and other libraries that provide Hash symbolisation, this method is kept within the Propono namespace and not mixed into Hash.
Class Method Details
.symbolize_keys(hash) ⇒ Object
Returns hash
with all primary and nested keys to string values symbolised To avoid conflicts with ActiveSupport and other libraries that provide Hash symbolisation, this method is kept within the Propono namespace and not mixed into Hash
7 8 9 10 11 12 13 14 |
# File 'lib/propono/utils.rb', line 7 def self.symbolize_keys(hash) hash.inject({}) do |result, (key, value)| new_key = key.is_a?(String) ? key.to_sym : key new_value = value.is_a?(Hash) ? symbolize_keys(value) : value result[new_key] = new_value result end end |