active_delegate 0.1.8 → 0.1.9

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: 59b7e693e22c66982f05158ef1df7ac3a1f5f1f2
4
- data.tar.gz: 198ecbb8547fe818fea48ddf07eb1ca5fdb879ea
3
+ metadata.gz: 4d157fcd42a41e6a9106addbf103a551543d9443
4
+ data.tar.gz: 181bc82d7f83e017d77438bee17a3fd1ff4225f5
5
5
  SHA512:
6
- metadata.gz: 168cede4634ec480bab04354409d72f6306cceccfb27ad5c18e6a51ea686d3e308da13a81572540cb461ab4735e73c46124f4f10d217d094f1d1707edbd3b7ff
7
- data.tar.gz: e71530500911af1ac072a82c4e0d29feb0e03a76ef0f23dfcd0b5ac9ec6a7ad79e1bd5286da0c29e41b4e4b9eeb6168b32d7bd07fb4e142fbe5aa85e81b20e66
6
+ metadata.gz: 19ab087839bd3766cb65f23caa4e9fc33d5bc7043b6488ccab65b67b2b5f222fd480a95f5c31474d1af6b06f8ddc473bbde2851d997530565816052cda366b16
7
+ data.tar.gz: 4c89f450c882dc11f0b0200c5631c82dabfbde717c319e2e107ed9a4fc8f559673595c65967a7294b0803061a097675de148565d3eb0cee8c819941a3b43321a
data/Gemfile.lock CHANGED
@@ -1,28 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_delegate (0.1.1)
4
+ active_delegate (0.1.2)
5
5
  activerecord (~> 5.0)
6
6
  i18n (~> 0.8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (5.1.1)
12
- activesupport (= 5.1.1)
13
- activerecord (5.1.1)
14
- activemodel (= 5.1.1)
15
- activesupport (= 5.1.1)
11
+ activemodel (5.1.4)
12
+ activesupport (= 5.1.4)
13
+ activerecord (5.1.4)
14
+ activemodel (= 5.1.4)
15
+ activesupport (= 5.1.4)
16
16
  arel (~> 8.0)
17
- activesupport (5.1.1)
17
+ activesupport (5.1.4)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (~> 0.7)
20
20
  minitest (~> 5.1)
21
21
  tzinfo (~> 1.1)
22
22
  arel (8.0.0)
23
23
  concurrent-ruby (1.0.5)
24
- i18n (0.8.4)
25
- minitest (5.10.2)
24
+ i18n (0.9.0)
25
+ concurrent-ruby (~> 1.0)
26
+ minitest (5.10.3)
26
27
  rake (10.5.0)
27
28
  thread_safe (0.3.6)
28
29
  tzinfo (1.2.3)
@@ -38,4 +39,4 @@ DEPENDENCIES
38
39
  rake (~> 10.0)
39
40
 
40
41
  BUNDLED WITH
41
- 1.14.6
42
+ 1.15.4
@@ -180,11 +180,13 @@ module ActiveDelegate
180
180
  attr_method = :"find_by_#{attrib}"
181
181
 
182
182
  @model.send(:define_singleton_method, attr_method) do |value|
183
- includes(attr_assoc).find_by(attr_table => { attr_name => value })
183
+ value = type_caster.type_cast_for_database(attr_name, value)
184
+ joins(attr_assoc).find_by(attr_table => { attr_name => value })
184
185
  end
185
186
 
186
187
  @model.send(:define_singleton_method, :"#{attr_method}!") do |value|
187
- includes(attr_assoc).find_by!(attr_table => { attr_name => value })
188
+ value = type_caster.type_cast_for_database(attr_name, value)
189
+ joins(attr_assoc).find_by!(attr_table => { attr_name => value })
188
190
  end
189
191
  end
190
192
 
@@ -195,23 +197,25 @@ module ActiveDelegate
195
197
  attr_blank = { attr_table => { attr_name => nil } }
196
198
 
197
199
  @model.scope :"with_#{attrib}", -> (*names) do
198
- named = { attr_table => { attr_name => names } }
199
-
200
200
  if names.empty?
201
- includes(attr_assoc).where.not(attr_blank)
201
+ left_outer_joins(attr_assoc).where.not(attr_blank)
202
202
  else
203
- includes(attr_assoc).where(named)
203
+ names = names.map { |n| type_caster.type_cast_for_database(attr_name, n) }
204
+ named = { attr_table => { attr_name => names } }
205
+
206
+ left_outer_joins(attr_assoc).where(named)
204
207
  end
205
208
  end
206
209
 
207
210
  @model.scope :"without_#{attrib}", -> (*names) do
208
- named = { attr_table => { attr_name => names } }
209
-
210
211
  if names.empty?
211
- includes(attr_assoc).where(attr_blank)
212
+ left_outer_joins(attr_assoc).where(attr_blank)
212
213
  else
213
- includes(attr_assoc).where(attr_blank)
214
- .or(includes(attr_assoc).where.not(named))
214
+ names = names.map { |n| type_caster.type_cast_for_database(attr_name, n) }
215
+ named = { attr_table => { attr_name => names } }
216
+
217
+ left_outer_joins(attr_assoc).where(attr_blank)
218
+ .or(left_outer_joins(attr_assoc).where.not(named))
215
219
  end
216
220
  end
217
221
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveDelegate
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_delegate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-15 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord