easy_translatable 0.2.0 → 0.2.1

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: 07c01316196483c2f6af68455278d9e92c16dd48
4
- data.tar.gz: 91caddf7318b585c7db393c4bda5784784e7b7b0
3
+ metadata.gz: d87d6fc4d906ec7164dc1afa51c00e91fb4a75a1
4
+ data.tar.gz: c667ece3ff6da305d1a92e5f10c842b49c412d00
5
5
  SHA512:
6
- metadata.gz: 61de0f484b7f8637f1ccff01d020eaa9ae3d47c24563c5dcbbec69de1f7643111f02dcc5e71ffb6d4c1b4f50fd9c1ab3dda40ab6379b98b6ba7fb3c7ecfe2817
7
- data.tar.gz: 82d6f692782508f0d5555f0f0cc833feab8446aee5d1b3991be66bf4498471e16adde80a81b3106e49975d225fec7ae9d611686ce6b741d45315d9c9c69eaa9e
6
+ metadata.gz: 86540d0c52254e9958ac5496d4dc146dac7671e7a16db19d19190a5eb4b9a850498d86fee171262cd4a0cecb761fb715881282fbf5e8f1f5a80beeeeb3fede68
7
+ data.tar.gz: 3a116572954e6de7d712b9c599f2d8c4f227ad253633eaf5269592d60767683eb0e8a5b90cf27ed1bfe50284d06034d996c0e4ffb76de25bf1959830610dd19d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2008, 2009, 2010 Sven Fuchs, Joshua Harvey, Clemens Kofler, John-Paul Bader, ClicRDV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
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) [![Build Status](https://travis-ci.org/popox/translatable.png)](https://travis-ci.org/popox/translatable) [![Coverage Status](https://coveralls.io/repos/popox/translatable/badge.png)](https://coveralls.io/r/popox/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/clicrdv/translatable.png)](https://codeclimate.com/github/clicrdv/translatable) [![Build Status](https://travis-ci.org/clicrdv/translatable.png)](https://travis-ci.org/clicrdv/translatable) [![Coverage Status](https://coveralls.io/repos/clicrdv/translatable/badge.png)](https://coveralls.io/r/clicrdv/translatable)
2
2
  ## Requirements
3
3
 
4
4
  * ActiveRecord 3.2
@@ -23,3 +23,6 @@ gem 'easy_translatable', '~> 0.1.0'
23
23
  - cleanup
24
24
  - doc
25
25
  - migration/model for translation table
26
+
27
+
28
+ Copyright (c) 2008, 2009, 2010 Sven Fuchs, Joshua Harvey, Clemens Kofler, John-Paul Bader, ClicRDV
@@ -39,18 +39,18 @@ module Translatable
39
39
  end
40
40
  end
41
41
 
42
- def on_after_save_callback(attr_names, callback)
43
- after_save callback, :if => Proc.new { |rec|
42
+ def condition_callback(attr_names, callback)
43
+ Proc.new { |rec|
44
44
  attr_names.any? do |translatable_attr|
45
45
  callback && rec.changes.keys.include?(translatable_attr.to_s)
46
46
  end
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)
50
+ %w(after_save before_save after_update before_update).each do |cb|
51
+ class_eval %{
52
+ def on_#{cb}_callback(attr_names, callback)
53
+ #{cb} callback, :if => condition_callback(attr_names, callback)
54
54
  end
55
55
  }
56
56
  end
@@ -179,7 +179,7 @@ module Translatable
179
179
  locale = respond_to?(:locale=) ? attributes.try(:[], :locale) :
180
180
  attributes.try(:delete, :locale)
181
181
 
182
- if locale
182
+ if locale && !respond_to?(:locale=)
183
183
  already = translate?
184
184
  translate unless translate?
185
185
  Translatable.with_locale(locale, &block)
@@ -26,6 +26,8 @@ module Translatable
26
26
 
27
27
  on_after_save_callback(attr_names, options[:after_save]) if options[:after_save]
28
28
  on_before_save_callback(attr_names, options[:before_save]) if options[:before_save]
29
+ on_after_update_callback(attr_names, options[:after_update]) if options[:after_update]
30
+ on_before_update_callback(attr_names, options[:before_update]) if options[:before_update]
29
31
 
30
32
  Translatable.add_translatable self
31
33
 
@@ -1,3 +1,3 @@
1
1
  module Translatable
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bonaud
@@ -164,6 +164,7 @@ executables: []
164
164
  extensions: []
165
165
  extra_rdoc_files: []
166
166
  files:
167
+ - LICENSE
167
168
  - README.md
168
169
  - lib/translatable.rb
169
170
  - lib/translatable/active_record.rb