polymorphic_join 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/polymorphic_join.rb +9 -6
- data/lib/polymorphic_join/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fd251d3029cdb8c257de506b471e1f54ee561079c9f0acf771012f8afb55e6d
|
4
|
+
data.tar.gz: 06a5c1834878040bdd5cde452bfbf6b6888df68f345293cfecc0a1dab4387d1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ce57792b3426e1aad896ab9158fa421b3bcee927ad98be31f7174d496cf331092f702ff5acad7a38e1fcb29a30ccade1b0fb20e9d7b6bc94461ee392e6f6de3
|
7
|
+
data.tar.gz: 2e1c899de63404ba46ec050e7efae4ed1b8c821eaa6a775f5c9dfa4907448fde9713160f1bed75a855059b4db87d58399a933a6e7c4a43bfbf8ea5026b09f685
|
data/lib/polymorphic_join.rb
CHANGED
@@ -80,16 +80,19 @@ module PolymorphicJoin
|
|
80
80
|
|
81
81
|
protected
|
82
82
|
|
83
|
+
def build_union(left, right)
|
84
|
+
if right.length > 1
|
85
|
+
Arel::Nodes::Union.new(left, build_union(right[0], right[1..-1]))
|
86
|
+
else
|
87
|
+
Arel::Nodes::Union.new(left, right[0])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
83
91
|
def polymorphic_union_scope(type, refs, *scopes)
|
84
92
|
union = scopes[0]
|
85
93
|
t2 = arel_table
|
86
94
|
|
87
|
-
if scopes.length > 1
|
88
|
-
(1..(scopes.length - 1)).each do |i|
|
89
|
-
union = union.union(scopes[i])
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
95
|
+
union = build_union(scopes[0], scopes[1..-1]) if scopes.length > 1
|
93
96
|
types = type.to_s.pluralize
|
94
97
|
t1 = arel_table.create_table_alias(union, types)
|
95
98
|
from(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polymorphic_join
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Huynh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|