Module: Mobility::Plugins::Fallbacks::BackendInstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#read(locale, fallback: true, **kwargs) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/mobility/plugins/fallbacks.rb', line 151

def read(locale, fallback: true, **kwargs)
  return super(locale, **kwargs) if !fallback || kwargs[:locale]

  locales = fallback == true ? self.class.fallbacks[locale] : [locale, *fallback]
  locales.each do |fallback_locale|
    value = super(fallback_locale, **kwargs)
    return value if Util.present?(value)
  end

  super(locale, **kwargs)
end