easy_translatable 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3dee420c21d08169dd364a987b32d7122672ed17
|
|
4
|
+
data.tar.gz: cfcf49aa29e11887d4354952870f70346d55b7c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61292672c77e9e2d07296b2ab88bd5974516184f3ae8e148b4490f216f3c8f75c18663f057cfecb153bc9ad730f007490ffe80e2549e5e257837d92cef1d6f9d
|
|
7
|
+
data.tar.gz: 7932851170e4e303493c6317d3705fd67a4b22f7ca3ffec69ed878e27e3290b51a6137a0cb82e3586045c764c53ab3e22aeef4499d0c901b2bc0a952f02000e2
|
|
@@ -38,6 +38,15 @@ module Translatable
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
def on_save_callback(attr_names, callback)
|
|
43
|
+
after_save callback, :if => Proc.new { |rec|
|
|
44
|
+
attr_names.any? do |translatable_attr|
|
|
45
|
+
callback && rec.changes.keys.include?(translatable_attr.to_s)
|
|
46
|
+
end
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
41
50
|
end
|
|
42
51
|
end
|
|
43
52
|
end
|
|
@@ -24,6 +24,8 @@ module Translatable
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
on_save_callback(attr_names, options[:after_save]) if options[:after_save]
|
|
28
|
+
|
|
27
29
|
Translatable.add_translatable self
|
|
28
30
|
|
|
29
31
|
end
|
|
@@ -45,6 +47,7 @@ module Translatable
|
|
|
45
47
|
options[:table_name] ||= Translatable.translation_class.table_name
|
|
46
48
|
options[:foreign_key] ||= 'record_id'
|
|
47
49
|
options[:conditions] ||= ''
|
|
50
|
+
options[:after_save] ||= false
|
|
48
51
|
|
|
49
52
|
class_attribute :translated_attribute_names, :translation_options, :fallbacks_for_empty_translations, :translated_serialized_attributes
|
|
50
53
|
self.translated_attribute_names = []
|
data/lib/translatable/version.rb
CHANGED