Module: Globalize::Model::ActiveRecord::Translated::InstanceMethods
- Defined in:
- lib/globalize/model/active_record/translated.rb
Instance Method Summary collapse
- #globalize ⇒ Object
- #reload(options = nil) ⇒ Object
- #set_translations(options) ⇒ Object
- #translated_locales ⇒ Object
- #update_globalize_record ⇒ Object
Instance Method Details
#globalize ⇒ Object
148 149 150 |
# File 'lib/globalize/model/active_record/translated.rb', line 148 def globalize @globalize ||= Adapter.new self end |
#reload(options = nil) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/globalize/model/active_record/translated.rb', line 136 def reload( = nil) globalize.clear # clear all globalized attributes # TODO what's the best way to handle this? self.class.[:translated_attributes].each do |attr| @attributes.delete attr.to_s end super end |
#set_translations(options) ⇒ Object
160 161 162 163 164 165 166 167 |
# File 'lib/globalize/model/active_record/translated.rb', line 160 def set_translations .keys.each do |key| translation = globalize_translations.find_by_locale(key.to_s) || globalize_translations.build(:locale => key.to_s) translation.update_attributes!([key]) end end |
#translated_locales ⇒ Object
156 157 158 |
# File 'lib/globalize/model/active_record/translated.rb', line 156 def translated_locales globalize_translations.scoped(:select => 'DISTINCT locale').map {|gt| gt.locale.to_sym } end |
#update_globalize_record ⇒ Object
152 153 154 |
# File 'lib/globalize/model/active_record/translated.rb', line 152 def update_globalize_record globalize.update_translations! end |