class I18nAdmin::HstoreBackend::Store
Public Instance Methods
[](path)
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 12 def [](path) locale, key = locale_and_key_from(path) cached_translations_for(locale).translations[key] end
store_translations(locale, key, value)
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 17 def store_translations(locale, key, value) translations_set = translations_set_for(locale) translations_set.translations[key] = value translations_set.translations_will_change! translations_set.save value end
translations_for(locale)
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 25 def translations_for(locale) translations_set_for(locale).translations end
Private Instance Methods
cached_translations_for(locale)
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 41 def cached_translations_for(locale) store_key = store_key_for(locale, :set) request_store.store[store_key] ||= translations_set_for(locale) end
locale_and_key_from(path)
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 31 def locale_and_key_from(path) path.split('.', 2) end
model()
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 46 def model @model ||= I18nAdmin::TranslationsSet end
translations_set_for(locale)
click to toggle source
# File lib/i18n_admin/hstore_backend.rb, line 35 def translations_set_for(locale) model.where(locale: locale).first_or_initialize do |set| set.translations ||= {} end end