Class: Nuntius::I18nStore
- Inherits:
-
Object
- Object
- Nuntius::I18nStore
- Defined in:
- lib/nuntius/i18n_store.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ I18nStore
constructor
A new instance of I18nStore.
- #keys ⇒ Object
- #template ⇒ Object
- #template=(template) ⇒ Object
- #with(template) ⇒ Object
Constructor Details
#initialize ⇒ I18nStore
Returns a new instance of I18nStore.
25 26 |
# File 'lib/nuntius/i18n_store.rb', line 25 def initialize end |
Instance Method Details
#[](key) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nuntius/i18n_store.rb', line 38 def [](key) return unless template result = {} locales.each do |locale| hash = flat_hash(locale.data).transform_values { |v| JSON.encode(v) } result.merge! hash end result[key] end |
#[]=(key, value) ⇒ Object
49 50 51 |
# File 'lib/nuntius/i18n_store.rb', line 49 def []=(key, value) # NOOP end |
#keys ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/nuntius/i18n_store.rb', line 28 def keys return [] unless template result = [] locales.each do |locale| result += flat_hash(locale.data).keys end result end |
#template ⇒ Object
61 62 63 |
# File 'lib/nuntius/i18n_store.rb', line 61 def template Thread.current[:nuntius_i18n_store_template] end |
#template=(template) ⇒ Object
65 66 67 |
# File 'lib/nuntius/i18n_store.rb', line 65 def template=(template) Thread.current[:nuntius_i18n_store_template] = template end |
#with(template) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/nuntius/i18n_store.rb', line 53 def with(template) with_custom_backend do self.template = template yield(template) self.template = nil end end |