Sha256: 4716e3a261835603d3f5c8c5647f20f24f195a2723db50c6a096255975bcf3fb
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# encoding: utf-8 module PagesCore module Localizable # = Localizable::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(Localizable::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) Localizable::Configuration.new( superclass.localizable_configuration.attributes.dup ) else Localizable::Configuration.new end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.4.3 | lib/pages_core/localizable/class_methods.rb |
pages_core-3.4.2 | lib/pages_core/localizable/class_methods.rb |