instance method
flatten_keys
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18Signature
flatten_keys(hash, escape, prev_key=nil, &block)
Flatten keys for nested Hashes by chaining up keys:
>> { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}.wind
=> { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i" => "j" }
Parameters
-
hashreq -
escapereq -
prev_keyopt = nil -
blockblock
Source
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/flatten.rb, line 54
def flatten_keys(hash, escape, prev_key=nil, &block)
hash.each_pair do |key, value|
key = escape_default_separator(key) if escape
curr_key = [prev_key, key].compact.join(FLATTEN_SEPARATOR).to_sym
yield curr_key, value
flatten_keys(value, escape, curr_key, &block) if value.is_a?(Hash)
end
end
Defined in activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/flatten.rb line 54
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in I18n::Backend::Flatten