Module: LocalizableModel::ClassMethods
- Defined in:
- lib/localizable_model/class_methods.rb
Overview
LocalizableModel::ClassMethods
Class methods for all Localizable models.
Instance Method Summary collapse
-
#in_locale(locale) ⇒ Object
Returns a scope where all records will be set to the given locale.
-
#localizable_configuration ⇒ Object
Accessor for the configuration.
-
#localized(locale) ⇒ Object
Returns a scope with only records matching the given locale.
- #localized_attributes ⇒ Object
Instance Method Details
#in_locale(locale) ⇒ Object
Returns a scope where all records will be set to the given locale.
11 12 13 14 15 16 |
# File 'lib/localizable_model/class_methods.rb', line 11 def in_locale(locale) all .extending(LocalizableModel::ScopeExtension) .localize(locale) .includes(:localizations) end |
#localizable_configuration ⇒ Object
Accessor for the configuration.
33 34 35 |
# File 'lib/localizable_model/class_methods.rb', line 33 def localizable_configuration @localizable_configuration ||= inherited_localizable_configuration end |
#localized(locale) ⇒ Object
Returns a scope with only records matching the given locale.
Page.localized('en').first.locale # => 'en'
22 23 24 25 26 |
# File 'lib/localizable_model/class_methods.rb', line 22 def localized(locale) in_locale(locale) .where("localizations.locale = ?", locale) .references(:localizations) end |
#localized_attributes ⇒ Object
28 29 30 |
# File 'lib/localizable_model/class_methods.rb', line 28 def localized_attributes localizable_configuration.attributes.keys end |