activerecord_nested_scope 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activerecord_nested_scope/builder.rb +12 -8
- data/lib/activerecord_nested_scope/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: a69c4a48717739fd16dacdb44003583d15f8989c
|
4
|
+
data.tar.gz: 7362eef6445f2ca2969cd9df5d04618c30aedba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43628d21ea4aae5f2dd93d78e913eb7a659b0fab1232a2a0a183f0cbf46f0a39ea6485176edb1dac944bfeb41c136f77fbce9a3defef4da93d9cc5f8b8f7677e
|
7
|
+
data.tar.gz: b832f7295a60cd32e4af55507cf7a05a504179c0658c6d025ce77def50582e7c6aac24fbf800204801521482bed18c8b5fbbf7ee32fe230328e3f129785bb195
|
@@ -53,14 +53,18 @@ module ActiveRecordNestedScope
|
|
53
53
|
|
54
54
|
def belongs_to_polymorphic_relation(klass, ref)
|
55
55
|
types = klass.unscoped.group(ref.foreign_type).pluck(ref.foreign_type)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
if types.present?
|
57
|
+
rels = types.map { |type|
|
58
|
+
if (parent = type.safe_constantize)
|
59
|
+
klass.where(ref.foreign_type => type, ref.foreign_key => build_for(parent).merge(scoped(parent, ref.scope)))
|
60
|
+
else
|
61
|
+
klass.none
|
62
|
+
end
|
63
|
+
}
|
64
|
+
union(klass, rels)
|
65
|
+
else
|
66
|
+
klass.none
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
def root_relation(klass)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_nested_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshikazu Kaneta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|