14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/zlocalize/rails/translated_attributes_serializer.rb', line 14
def serialize_translations(attribute_names,options = {})
serialize :translated_attributes, HashWithIndifferentAccess
[attribute_names].flatten.each do |attr_name|
class_eval "def #{attr_name}(options = {})
read_translated_attribute('#{attr_name}',(options[:locale] || ZLocalize.locale).to_s)
end"
end
class_eval "after_initialize do
self.translated_attributes ||= HashWithIndifferentAccess.new
end
def translated_attributes=(value)
self.translations = value
end"
include ZLocalize::Translatable::TranslatedAttributesSerializer::InstanceMethods
end
|