easy_translatable 0.1.5 → 0.1.6

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: 3dee420c21d08169dd364a987b32d7122672ed17
4
- data.tar.gz: cfcf49aa29e11887d4354952870f70346d55b7c5
3
+ metadata.gz: 4bf467e734ff69ca81e47edf7fcbb917b59e84a8
4
+ data.tar.gz: 76bc1946777bc451dce2f741e519ea9ef338266d
5
5
  SHA512:
6
- metadata.gz: 61292672c77e9e2d07296b2ab88bd5974516184f3ae8e148b4490f216f3c8f75c18663f057cfecb153bc9ad730f007490ffe80e2549e5e257837d92cef1d6f9d
7
- data.tar.gz: 7932851170e4e303493c6317d3705fd67a4b22f7ca3ffec69ed878e27e3290b51a6137a0cb82e3586045c764c53ab3e22aeef4499d0c901b2bc0a952f02000e2
6
+ metadata.gz: f5c47b00241ee66bf92180d7811fadab41dcf66bf58d117b109a2e6a918488f47c7d7b0fcccba0f1eddc9eae7f3907af518d0ae0cb686bbea70405f6ad27d73c
7
+ data.tar.gz: 54cb446e8f2ea1a018014bec4db87b377874e3fb2f64577efb491e14e2924bd714d5d12aa21cb6cdde95e8b2e3c581df41dac431c52456312a30342d167c755f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Translatable
1
+ # Translatable [![Gem Version](https://badge.fury.io/rb/easy_translatable.png)](http://badge.fury.io/rb/easy_translatable) [![Code Climate](https://codeclimate.com/github/popox/translatable.png)](https://codeclimate.com/github/popox/translatable)
2
2
 
3
3
  ## Requirements
4
4
 
@@ -25,4 +25,4 @@ gem 'easy_translatable', '~> 0.1.0'
25
25
  - cleanup
26
26
  - doc
27
27
  - migration/model for translation table
28
- - serialized attributes (JSON/YML)
28
+ - serialized attributes (JSON/YML)
@@ -39,7 +39,7 @@ module Translatable
39
39
  end
40
40
  end
41
41
 
42
- def on_save_callback(attr_names, callback)
42
+ def on_after_save_callback(attr_names, callback)
43
43
  after_save callback, :if => Proc.new { |rec|
44
44
  attr_names.any? do |translatable_attr|
45
45
  callback && rec.changes.keys.include?(translatable_attr.to_s)
@@ -47,6 +47,14 @@ module Translatable
47
47
  }
48
48
  end
49
49
 
50
+ def on_before_save_callback(attr_names, callback)
51
+ before_save callback, :if => Proc.new { |rec|
52
+ attr_names.any? do |translatable_attr|
53
+ callback && rec.changes.keys.include?(translatable_attr.to_s)
54
+ end
55
+ }
56
+ end
57
+
50
58
  end
51
59
  end
52
60
  end
@@ -24,7 +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]
27
+ on_after_save_callback(attr_names, options[:after_save]) if options[:after_save]
28
+ on_before_save_callback(attr_names, options[:before_save]) if options[:before_save]
28
29
 
29
30
  Translatable.add_translatable self
30
31
 
@@ -48,6 +49,7 @@ module Translatable
48
49
  options[:foreign_key] ||= 'record_id'
49
50
  options[:conditions] ||= ''
50
51
  options[:after_save] ||= false
52
+ options[:before_save] ||= false
51
53
 
52
54
  class_attribute :translated_attribute_names, :translation_options, :fallbacks_for_empty_translations, :translated_serialized_attributes
53
55
  self.translated_attribute_names = []
@@ -1,3 +1,3 @@
1
1
  module Translatable
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bonaud