easy_translatable 0.3.0 → 0.3.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: ff59051dd5f5534569166f4b31b9ee93a7a637cd
4
- data.tar.gz: 72c756caaca02663bc0fe02d61145b568f24324d
3
+ metadata.gz: d6d5a48b4e1cdd3ad7007081bdfe0561dd1a429c
4
+ data.tar.gz: 52e60d36a522792167113c202d9c14eeb90dc628
5
5
  SHA512:
6
- metadata.gz: c603dbf48910d7bb8502408856ad56c9f3a9c8e14d12bbb071667bf8a3c8534ef5cd7d6e6876f56da503d290964602b7266fab076396e74b969ad985f7f03b4c
7
- data.tar.gz: e2197b3097c3aef681045e244ac0ef60a3b017e2fbbbd4a5bcfa05d5c8766f58912f15e4710143dbbfd03a86c79efd8aef31e5330b46380553e82820b46d4838
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[:conditions],
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
@@ -1,3 +1,3 @@
1
1
  module Translatable
2
- VERSION = '0.3.0'
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.0
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.0
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