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 +4 -4
- data/README.md +2 -2
- data/lib/translatable/active_record/class_methods.rb +9 -1
- data/lib/translatable/active_record/macro.rb +3 -1
- data/lib/translatable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4bf467e734ff69ca81e47edf7fcbb917b59e84a8
|
|
4
|
+
data.tar.gz: 76bc1946777bc451dce2f741e519ea9ef338266d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5c47b00241ee66bf92180d7811fadab41dcf66bf58d117b109a2e6a918488f47c7d7b0fcccba0f1eddc9eae7f3907af518d0ae0cb686bbea70405f6ad27d73c
|
|
7
|
+
data.tar.gz: 54cb446e8f2ea1a018014bec4db87b377874e3fb2f64577efb491e14e2924bd714d5d12aa21cb6cdde95e8b2e3c581df41dac431c52456312a30342d167c755f
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Translatable
|
|
1
|
+
# Translatable [](http://badge.fury.io/rb/easy_translatable) [](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
|
|
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
|
-
|
|
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 = []
|
data/lib/translatable/version.rb
CHANGED