Module: SingleTableGlobalize3
- Defined in:
- lib/single_table_globalize3/active_record/attributes.rb,
lib/single_table_globalize3.rb,
lib/single_table_globalize3/version.rb,
lib/single_table_globalize3/versioning.rb,
lib/single_table_globalize3/active_record.rb,
lib/single_table_globalize3/active_record/adapter.rb,
lib/single_table_globalize3/versioning/paper_trail.rb,
lib/single_table_globalize3/active_record/act_macro.rb,
lib/single_table_globalize3/active_record/exceptions.rb,
lib/single_table_globalize3/active_record/translation.rb,
lib/single_table_globalize3/active_record/class_methods.rb,
lib/generators/single_table_globalize3/migration_generator.rb,
lib/single_table_globalize3/active_record/instance_methods.rb,
lib/single_table_globalize3/active_record/with_translations.rb,
lib/single_table_globalize3/active_record/attribute_read_write.rb
Overview
Helper class for storing values per locale. Used by SingleTableGlobalize3::Adapter to stash and cache attribute values.
Defined Under Namespace
Modules: ActiveRecord, Versioning
Classes: MigrationGenerator
Constant Summary
collapse
- VERSION =
'0.0.5'
Class Method Summary
collapse
Class Method Details
.default_fallbacks(for_locale = self.locale) ⇒ Object
44
45
46
|
# File 'lib/single_table_globalize3.rb', line 44
def default_fallbacks(for_locale = self.locale)
i18n_fallbacks? ? I18n.fallbacks[for_locale] : [for_locale.to_sym]
end
|
.fallbacks(for_locale = self.locale) ⇒ Object
40
41
42
|
# File 'lib/single_table_globalize3.rb', line 40
def fallbacks(for_locale = self.locale)
read_fallbacks[for_locale] || default_fallbacks(for_locale)
end
|
.fallbacks=(locales) ⇒ Object
32
33
34
|
# File 'lib/single_table_globalize3.rb', line 32
def fallbacks=(locales)
set_fallbacks(locales)
end
|
.i18n_fallbacks? ⇒ Boolean
36
37
38
|
# File 'lib/single_table_globalize3.rb', line 36
def i18n_fallbacks?
I18n.respond_to?(:fallbacks)
end
|
.locale ⇒ Object
10
11
12
|
# File 'lib/single_table_globalize3.rb', line 10
def locale
read_locale || I18n.locale
end
|
.locale=(locale) ⇒ Object
14
15
16
|
# File 'lib/single_table_globalize3.rb', line 14
def locale=(locale)
set_locale(locale)
end
|
.with_locale(locale, &block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/single_table_globalize3.rb', line 18
def with_locale(locale, &block)
previous_locale = read_locale
set_locale(locale)
result = yield(locale)
set_locale(previous_locale)
result
end
|
.with_locales(*locales, &block) ⇒ Object
26
27
28
29
30
|
# File 'lib/single_table_globalize3.rb', line 26
def with_locales(*locales, &block)
locales.flatten.map do |locale|
with_locale(locale, &block)
end
end
|