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
129 130 131 |
# File 'lib/globalize/model/active_record/translated.rb', line 129 def globalize @globalize ||= Adapter.new self end |
#reload(options = nil) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/globalize/model/active_record/translated.rb', line 117 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
141 142 143 144 145 146 147 148 |
# File 'lib/globalize/model/active_record/translated.rb', line 141 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
137 138 139 |
# File 'lib/globalize/model/active_record/translated.rb', line 137 def translated_locales globalize_translations.scoped(:select => 'DISTINCT locale').map {|gt| gt.locale.to_sym } end |
#update_globalize_record ⇒ Object
133 134 135 |
# File 'lib/globalize/model/active_record/translated.rb', line 133 def update_globalize_record globalize.update_translations! end |