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 +4 -4
- data/Gemfile.lock +11 -10
- data/lib/active_delegate/attributes.rb +15 -11
- data/lib/active_delegate/version.rb +1 -1
- 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: 4d157fcd42a41e6a9106addbf103a551543d9443
|
4
|
+
data.tar.gz: 181bc82d7f83e017d77438bee17a3fd1ff4225f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
12
|
-
activesupport (= 5.1.
|
13
|
-
activerecord (5.1.
|
14
|
-
activemodel (= 5.1.
|
15
|
-
activesupport (= 5.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.
|
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.
|
25
|
-
|
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.
|
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
|
-
|
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
|
-
|
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
|
-
|
201
|
+
left_outer_joins(attr_assoc).where.not(attr_blank)
|
202
202
|
else
|
203
|
-
|
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
|
-
|
212
|
+
left_outer_joins(attr_assoc).where(attr_blank)
|
212
213
|
else
|
213
|
-
|
214
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|