Module: Globalize
- Defined in:
- lib/globalize/active_record/attributes.rb,
lib/globalize.rb,
lib/globalize/versioning.rb,
lib/globalize/active_record.rb,
lib/globalize/active_record/adapter.rb,
lib/globalize/active_record/act_macro.rb,
lib/globalize/active_record/migration.rb,
lib/globalize/active_record/exceptions.rb,
lib/globalize/active_record/translation.rb,
lib/globalize/versioning/vestal_versions.rb,
lib/globalize/active_record/class_methods.rb,
lib/globalize/active_record/instance_methods.rb
Overview
Helper class for storing values per locale. Used by Globalize::Adapter to stash and cache attribute values.
Defined Under Namespace
Modules: ActiveRecord, Versioning
Class Method Summary
collapse
Class Method Details
.fallbacks(locale = self.locale) ⇒ Object
30
31
32
|
# File 'lib/globalize.rb', line 30
def fallbacks(locale = self.locale)
fallbacks? ? I18n.fallbacks[locale] : [locale.to_sym]
end
|
.fallbacks? ⇒ Boolean
26
27
28
|
# File 'lib/globalize.rb', line 26
def fallbacks?
I18n.respond_to?(:fallbacks)
end
|
.locale ⇒ Object
10
11
12
|
# File 'lib/globalize.rb', line 10
def locale
read_locale || I18n.locale
end
|
.locale=(locale) ⇒ Object
14
15
16
|
# File 'lib/globalize.rb', line 14
def locale=(locale)
set_locale(locale)
end
|
.with_locale(locale, &block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/globalize.rb', line 18
def with_locale(locale, &block)
previous_locale = read_locale
set_locale(locale)
result = yield
set_locale(previous_locale)
result
end
|