Sha256: bd3fd6b94875f3e5d609a30329a14f54c8b16e6887c19791dd160f88339c05d6
Contents?: true
Size: 1.2 KB
Versions: 9
Compression:
Stored size: 1.2 KB
Contents
# encoding: utf-8 module LocalizableModel # = LocalizableModel::ClassMethods # # Class methods for all Localizable models. # module ClassMethods # Returns a scope where all records will be set to the given locale. # def in_locale(locale) all .extending(LocalizableModel::ScopeExtension) .localize(locale) .includes(:localizations) end # Returns a scope with only records matching the given locale. # # Page.localized('en').first.locale # => 'en' # def localized(locale) in_locale(locale) .where("localizations.locale = ?", locale) .references(:localizations) end def localized_attributes localizable_configuration.attributes.keys end # Accessor for the configuration. def localizable_configuration @localizable_configuration ||= inherited_localizable_configuration end private def inherited_localizable_configuration if superclass.respond_to?(:localizable_configuration) LocalizableModel::Configuration.new( superclass.localizable_configuration.attributes.dup ) else LocalizableModel::Configuration.new end end end end
Version data entries
9 entries across 9 versions & 1 rubygems