Module: Mobility::Plugins::Cache::BackendMethods
- Defined in:
- lib/mobility/plugins/cache.rb
Backend Accessors collapse
-
#read(locale, value, options = {}) ⇒ Object
Gets the translated value for provided locale from configured backend.
-
#write(locale, value, **options) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
Instance Method Summary collapse
Instance Method Details
#clear_cache ⇒ Object
82 83 84 |
# File 'lib/mobility/plugins/cache.rb', line 82 def clear_cache @cache = {} end |
#read(locale, value, options = {}) ⇒ Object
Gets the translated value for provided locale from configured backend.
64 65 66 67 68 69 70 71 |
# File 'lib/mobility/plugins/cache.rb', line 64 def read(locale, **) return super(locale, **) if .delete(:cache) == false if cache.has_key?(locale) cache[locale] else cache[locale] = super(locale, **) end end |
#write(locale, value, **options) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
76 77 78 79 |
# File 'lib/mobility/plugins/cache.rb', line 76 def write(locale, value, **) return super if .delete(:cache) == false cache[locale] = super end |