Class: I18n::Locale::Fallbacks
- Defined in:
- lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb
Constant Summary
Constants inherited from Hash
Constants included from ActiveSupport::CoreExtensions::Hash::Conversions
ActiveSupport::CoreExtensions::Hash::Conversions::DISALLOWED_XML_TYPES, ActiveSupport::CoreExtensions::Hash::Conversions::XML_FORMATTING, ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING, ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES
Instance Attribute Summary collapse
-
#defaults ⇒ Object
Returns the value of attribute defaults.
Instance Method Summary collapse
- #[](locale) ⇒ Object
-
#initialize(*mappings) ⇒ Fallbacks
constructor
A new instance of Fallbacks.
- #map(mappings) ⇒ Object
Methods inherited from Hash
#as_json, #deep_merge!, #deep_symbolize_keys, #except, #slice, #to_json
Methods included from ActiveSupport::CoreExtensions::Hash::Except
Methods included from ActiveSupport::CoreExtensions::Hash::Slice
Methods included from ActiveSupport::CoreExtensions::Hash::Diff
Methods included from ActiveSupport::CoreExtensions::Hash::Conversions
included, #rename_key, #to_query, #to_xml
Methods included from ActiveSupport::CoreExtensions::Hash::ReverseMerge
#reverse_merge, #reverse_merge!
Methods included from ActiveSupport::CoreExtensions::Hash::DeepMerge
Methods included from ActiveSupport::CoreExtensions::Hash::IndifferentAccess
Methods included from ActiveSupport::CoreExtensions::Hash::Keys
#assert_valid_keys, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!
Constructor Details
#initialize(*mappings) ⇒ Fallbacks
Returns a new instance of Fallbacks.
58 59 60 61 62 |
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb', line 58 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
#defaults ⇒ Object
Returns the value of attribute defaults.
67 68 69 |
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb', line 67 def defaults @defaults end |
Instance Method Details
#[](locale) ⇒ Object
69 70 71 72 73 |
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/locale/fallbacks.rb', line 69 def [](locale) raise InvalidLocale.new(locale) if locale.nil? locale = locale.to_sym super || store(locale, compute(locale)) end |