Module: Nanoc3::HashExtensions
- Included in:
- Hash
- Defined in:
- lib/nanoc3/base/core_ext/hash.rb
Instance Method Summary (collapse)
-
- (Hash) stringify_keys
Returns a new hash where all keys are recursively converted to strings by calling ArrayExtensions#stringify<em>keys or #stringify</em>keys.
-
- (Hash) symbolize_keys
Returns a new hash where all keys are recursively converted to symbols by calling ArrayExtensions#symbolize<em>keys or #symbolize</em>keys.
Instance Method Details
- (Hash) stringify_keys
Returns a new hash where all keys are recursively converted to strings by calling ArrayExtensions#stringify<em>keys or #stringify</em>keys.
21 22 23 24 25 |
# File 'lib/nanoc3/base/core_ext/hash.rb', line 21 def stringify_keys inject({}) do |hash, (key, value)| hash.merge(key.to_s => value.respond_to?(:stringify_keys) ? value.stringify_keys : value) end end |
- (Hash) symbolize_keys
Returns a new hash where all keys are recursively converted to symbols by calling ArrayExtensions#symbolize<em>keys or #symbolize</em>keys.
10 11 12 13 14 |
# File 'lib/nanoc3/base/core_ext/hash.rb', line 10 def symbolize_keys inject({}) do |hash, (key, value)| hash.merge(key.to_sym => value.respond_to?(:symbolize_keys) ? value.symbolize_keys : value) end end |