Module: Nanoc3::HashExtensions

encoding: utf-8

Public Visibility

Public Instance Method Summary

#stringify_keys

Returns a new hash where all keys are recursively converted to strings.

#symbolize_keys

Returns a new hash where all keys are recursively converted into symbols.

Public Instance Method Details

stringify_keys

public stringify_keys

Returns a new hash where all keys are recursively converted to strings.

[View source]


13
14
15
16
17
# File 'lib/nanoc3/base/core_ext/hash.rb', line 13

def stringify_keys
  inject({}) do |hash, (key, value)|
    hash.merge(key.to_s => value.respond_to?(:stringify_keys) ? value.stringify_keys : value)
  end
end

symbolize_keys

public symbolize_keys

Returns a new hash where all keys are recursively converted into symbols.

[View source]


6
7
8
9
10
# File 'lib/nanoc3/base/core_ext/hash.rb', line 6

def symbolize_keys
  inject({}) do |hash, (key, value)|
    hash.merge(key.to_sym => value.respond_to?(:symbolize_keys) ? value.symbolize_keys : value)
  end
end
Generated on Sunday, August 09 2009 at 01:43:15 PM by YARD 0.2.3.2 (ruby-1.8.7).