easy_translatable 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a2db1f63c194bb5c4ff3014938c96f635ad2f17
4
- data.tar.gz: 296172fd483778a4e593c659bb2b4a30c665ad53
3
+ metadata.gz: 3dee420c21d08169dd364a987b32d7122672ed17
4
+ data.tar.gz: cfcf49aa29e11887d4354952870f70346d55b7c5
5
5
  SHA512:
6
- metadata.gz: e63d023cdde40a254c4874f81f892ecf28c28143d6857008776f3cf1efe49edf959034c8e6d45320fe1562ee44eeace6efced3161775a72e96a089c0a47e568b
7
- data.tar.gz: 8908a1addd1f71c87c15ac9033d5c0ad27a6ae8fde08616cc398e159a721267a946fd7b528450427528b9d5c992967af6592246eef967a16a4e581e05b536ee2
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 = []
@@ -1,3 +1,3 @@
1
1
  module Translatable
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_translatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bonaud