Class: Mobility::Backends::Hash
- Inherits:
-
Object
- Object
- Mobility::Backends::Hash
- Includes:
- Mobility::Backend
- Defined in:
- lib/mobility/backends/hash.rb
Overview
Backend which stores translations in an in-memory hash.
Instance Attribute Summary
Attributes included from Mobility::Backend
Backend Accessors collapse
-
#read(locale, _ = {}) ⇒ Object
Gets the translated value for provided locale from configured backend.
-
#write(locale, value, _ = {}) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
Instance Method Summary collapse
-
#each_locale {|Locale| ... } ⇒ Object
Yields locales available for this attribute.
Methods included from Mobility::Backend
#==, #each, included, #initialize, #locales, #model_class, #options, #present?
Instance Method Details
#each_locale {|Locale| ... } ⇒ Object
Yields locales available for this attribute.
26 27 28 |
# File 'lib/mobility/backends/hash.rb', line 26 def each_locale translations.each { |l, _| yield l } end |
#read(locale, _ = {}) ⇒ Object
Gets the translated value for provided locale from configured backend.
14 15 16 |
# File 'lib/mobility/backends/hash.rb', line 14 def read(locale, _ = {}) translations[locale] end |
#write(locale, value, _ = {}) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
20 21 22 |
# File 'lib/mobility/backends/hash.rb', line 20 def write(locale, value, _ = {}) translations[locale] = value end |