Module: PagesCore::Localizable::ClassMethods
- Defined in:
- lib/pages_core/localizable/class_methods.rb
Overview
Localizable::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.
12 13 14 15 16 17 |
# File 'lib/pages_core/localizable/class_methods.rb', line 12 def in_locale(locale) all .extending(Localizable::ScopeExtension) .localize(locale) .includes(:localizations) end |
#localizable_configuration ⇒ Object
Accessor for the configuration.
34 35 36 |
# File 'lib/pages_core/localizable/class_methods.rb', line 34 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'
23 24 25 26 27 |
# File 'lib/pages_core/localizable/class_methods.rb', line 23 def localized(locale) in_locale(locale) .where("localizations.locale = ?", locale) .references(:localizations) end |
#localized_attributes ⇒ Object
29 30 31 |
# File 'lib/pages_core/localizable/class_methods.rb', line 29 def localized_attributes localizable_configuration.attributes.keys end |