Module: Mobility::Plugins::Presence
- Defined in:
- lib/mobility/plugins/presence.rb
Overview
Applies presence filter to values fetched from backend and to values set on backend. Included by default, but can be disabled with presence: false option.
Backend Accessors collapse
-
#read(locale, **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.
Class Method Summary collapse
-
.apply(attributes, option) ⇒ Object
Applies presence plugin to attributes.
Class Method Details
.apply(attributes, option) ⇒ Object
Applies presence plugin to attributes.
15 16 17 |
# File 'lib/mobility/plugins/presence.rb', line 15 def self.apply(attributes, option) attributes.backend_class.include(self) if option end |
Instance Method Details
#read(locale, **options) ⇒ Object
Gets the translated value for provided locale from configured backend.
23 24 25 26 27 |
# File 'lib/mobility/plugins/presence.rb', line 23 def read(locale, **) return super if .delete(:presence) == false value = super value == false ? value : Util.presence(value) end |
#write(locale, value, **options) ⇒ Object
Updates translation for provided locale without calling backend’s methods to persist the changes.
33 34 35 36 |
# File 'lib/mobility/plugins/presence.rb', line 33 def write(locale, value, **) return super if .delete(:presence) == false super(locale, value == false ? value : Util.presence(value), ) end |