easy_translatable 0.2.0 → 0.2.1
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: d87d6fc4d906ec7164dc1afa51c00e91fb4a75a1
|
4
|
+
data.tar.gz: c667ece3ff6da305d1a92e5f10c842b49c412d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 [](http://badge.fury.io/rb/easy_translatable) [](http://badge.fury.io/rb/easy_translatable) [](https://codeclimate.com/github/clicrdv/translatable) [](https://travis-ci.org/clicrdv/translatable) [](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
|
43
|
-
|
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
|
-
|
51
|
-
|
52
|
-
attr_names
|
53
|
-
callback
|
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
|
|
data/lib/translatable/version.rb
CHANGED
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.
|
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
|