Class: I18n::Locale::Fallbacks
- Inherits:
-
Hash
- Object
- Hash
- I18n::Locale::Fallbacks
- Defined in:
- lib/i18n/locale/fallbacks.rb
Constant Summary
Constant Summary
Constants inherited from Hash
Instance Attribute Summary (collapse)
-
- (Object) defaults
Returns the value of attribute defaults.
Instance Method Summary (collapse)
- - (Object) [](locale)
-
- (Fallbacks) initialize(*mappings)
constructor
A new instance of Fallbacks.
- - (Object) map(mappings)
Methods inherited from Hash
#deep_merge!, #deep_symbolize_keys, #except, #slice
Constructor Details
- (Fallbacks) initialize(*mappings)
A new instance of Fallbacks
56 57 58 59 60 |
# File 'lib/i18n/locale/fallbacks.rb', line 56 def initialize(*mappings) @map = {} map(mappings.pop) if mappings.last.is_a?(Hash) self.defaults = mappings.empty? ? [I18n.default_locale.to_sym] : mappings end |
Instance Attribute Details
- (Object) defaults
Returns the value of attribute defaults
65 66 67 |
# File 'lib/i18n/locale/fallbacks.rb', line 65 def defaults @defaults end |
Instance Method Details
- (Object) [](locale)
67 68 69 70 71 |
# File 'lib/i18n/locale/fallbacks.rb', line 67 def [](locale) raise InvalidLocale.new(locale) if locale.nil? locale = locale.to_sym super || store(locale, compute(locale)) end |
- (Object) map(mappings)
73 74 75 76 77 78 79 80 81 |
# File 'lib/i18n/locale/fallbacks.rb', line 73 def map(mappings) mappings.each do |from, to| from, to = from.to_sym, Array(to) to.each do |_to| @map[from] ||= [] @map[from] << _to.to_sym end end end |