easy_translatable 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/translatable/active_record/macro.rb +12 -2
- data/lib/translatable/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d5a48b4e1cdd3ad7007081bdfe0561dd1a429c
|
4
|
+
data.tar.gz: 52e60d36a522792167113c202d9c14eeb90dc628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53fc2b2560d9eeeec311705c39eb1cf8b6a3fbc528df54f6bd0a7ea04efe081c7998a58337604d5cc6056e8b58a03e3fbf78121599610452665af9e517561a4f
|
7
|
+
data.tar.gz: e3eca0c22e70e6890f333fd27d7a0473d280d719ad21630b7fc0f9c9170bf90343c7f466c7c49b41e191942a770e92aad4afb9b882e837e4a278c2e00104897d
|
@@ -49,7 +49,7 @@ module Translatable
|
|
49
49
|
def setup_translatable!(options)
|
50
50
|
options[:table_name] ||= Translatable.translation_class.table_name
|
51
51
|
options[:foreign_key] ||= 'record_id'
|
52
|
-
options[:conditions] ||=
|
52
|
+
options[:conditions] ||= {}
|
53
53
|
options[:after_save] ||= false
|
54
54
|
options[:before_save] ||= false
|
55
55
|
|
@@ -66,7 +66,7 @@ module Translatable
|
|
66
66
|
|
67
67
|
has_many :translations, :class_name => translation_class.name,
|
68
68
|
:foreign_key => options[:foreign_key],
|
69
|
-
:conditions => options
|
69
|
+
:conditions => conditions(options),
|
70
70
|
:dependent => :destroy,
|
71
71
|
:extend => HasManyExtensions,
|
72
72
|
:autosave => false
|
@@ -74,6 +74,16 @@ module Translatable
|
|
74
74
|
after_create :save_translations!
|
75
75
|
after_update :save_translations!
|
76
76
|
end
|
77
|
+
|
78
|
+
def conditions(options)
|
79
|
+
table_name = self.table_name
|
80
|
+
proc {
|
81
|
+
c = options[:conditions]
|
82
|
+
c = self.instance_eval(&c) if c.is_a?(Proc)
|
83
|
+
c.merge(:scope => table_name, :locale => Translatable.locale)
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
77
87
|
end
|
78
88
|
|
79
89
|
module HasManyExtensions
|
data/lib/translatable/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Translatable
|
2
|
-
VERSION = '0.3.
|
3
|
-
end
|
2
|
+
VERSION = '0.3.1'
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Bonaud
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.2.
|
200
|
+
rubygems_version: 2.2.2
|
201
201
|
signing_key:
|
202
202
|
specification_version: 4
|
203
203
|
summary: Handle translations for AR models into a single table
|