Module: Mobility::Plugins::Presence::BackendMethods

Defined in:
lib/mobility/plugins/presence.rb

Backend Accessors collapse

Instance Method Details

#read(locale, **options) ⇒ Object

Gets the translated value for provided locale from configured backend.

Parameters:

  • locale (Symbol)

    Locale to read

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • presence (Boolean)

    false to disable presence filter.

Returns:

  • (Object)

    Value of translation



31
32
33
# File 'lib/mobility/plugins/presence.rb', line 31

def read(locale, **options)
  options.delete(:presence) == false ? super : Presence[super]
end

#write(locale, value, **options) ⇒ Object

Updates translation for provided locale without calling backend’s methods to persist the changes.

Parameters:

  • locale (Symbol)

    Locale to write

  • value (Object)

    Value to write

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • presence (Boolean)

    false to disable presence filter.

Returns:

  • (Object)

    Updated value



38
39
40
41
42
43
44
# File 'lib/mobility/plugins/presence.rb', line 38

def write(locale, value, **options)
  if options.delete(:presence) == false
    super
  else
    super(locale, Presence[value], **options)
  end
end