4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/globalize/active_record/act_macro.rb', line 4
def translates(*attr_names)
options = attr_names.
setup_translates!(options) unless translates?
attr_names = attr_names.map(&:to_sym)
attr_names -= translated_attribute_names if defined?(translated_attribute_names)
if attr_names.present?
translation_class.instance_eval %{
attr_accessible :#{attr_names.join(', :')}
}
attr_names.each do |attr_name|
serializer = self.serialized_attributes[attr_name.to_s]
if serializer.present?
if defined?(::ActiveRecord::Coders::YAMLColumn) &&
serializer.is_a?(::ActiveRecord::Coders::YAMLColumn)
serializer = serializer.object_class
end
translation_class.send :serialize, attr_name, serializer
end
translated_attr_accessor(attr_name)
translations_accessor(attr_name)
self.translated_attribute_names << attr_name
end
end
end
|