Module: Mobility::Plugins::Default::BackendMethods

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

Backend Accessors collapse

Instance Method Details

#read(locale, accessor_options = {}) ⇒ Object

Gets the translated value for provided locale from configured backend.

Parameters:

  • locale (Symbol)

    Locale to read

  • accessor_options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (accessor_options):

  • default (Boolean)

    false to disable presence filter.

Returns:

  • (Object)

    Value of translation



91
92
93
94
95
96
97
98
# File 'lib/mobility/plugins/default.rb', line 91

def read(locale, accessor_options = {})
  default = accessor_options.has_key?(:default) ? accessor_options.delete(:default) : options[:default]
  if (value = super(locale, **accessor_options)).nil?
    Default[default, locale: locale, accessor_options: accessor_options, model: model, attribute: attribute]
  else
    value
  end
end