class Mongoid::Globalize::Attributes
Public Instance Methods
[](locale)
click to toggle source
Returns translations for given locale. Creates empty hash for locale, if given locale doesn’t present. Param: String or Symbol - locale Result: Hash of translations
# File lib/mongoid_globalize/attributes.rb, line 10 def [](locale) locale = locale.to_sym self[locale] = {} unless has_key?(locale) self.fetch(locale) end
contains?(locale, name)
click to toggle source
Checks that given locale has translation for given name. Param: String or Symbol - locale Param: String or Symbol - name of field Result: true or false
# File lib/mongoid_globalize/attributes.rb, line 20 def contains?(locale, name) self[locale].has_key?(name.to_s) end
read(locale, name)
click to toggle source
Returns translation for given name and given locale. Param: String or Symbol - locale Param: String or Symbol - name of field Result: Object
# File lib/mongoid_globalize/attributes.rb, line 28 def read(locale, name) self[locale][name.to_s] end
write(locale, name, value)
click to toggle source
Writes translation for given name and given locale. Param: String or Symbol - locale Param: String or Symbol - name of field Param: Object
# File lib/mongoid_globalize/attributes.rb, line 36 def write(locale, name, value) #raise 'z' if value.nil? # TODO self[locale][name.to_s] = value end