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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b76e612525e8f4409bdf8f89a0b8451df5de9651
4
- data.tar.gz: 4a17a65653f1809dd4104a2cbb5710dd31503d67
3
+ metadata.gz: a69c4a48717739fd16dacdb44003583d15f8989c
4
+ data.tar.gz: 7362eef6445f2ca2969cd9df5d04618c30aedba5
5
5
  SHA512:
6
- metadata.gz: '08365cd0dbccd23a4a09b994e0cc2b197de117fc2077b660cf2287738f28e3f8d97eb1b9ab0d28faa6bcbd5b2015a26687b7517da95bcefba86ebc225b7f42c2'
7
- data.tar.gz: 35f13fa1be4f5b04722fa1d99f736fa3b5cb8b1477f4e2c54e1832543deb034e6e4f37ff9ebc4efdc2771ebe04e8a4ef69ac8e603e87ff01e6cd6707e6455511
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
- rels = types.map { |type|
57
- if (parent = type.safe_constantize)
58
- klass.where(ref.foreign_type => type, ref.foreign_key => build_for(parent).merge(scoped(parent, ref.scope)))
59
- else
60
- klass.none
61
- end
62
- }
63
- union(klass, rels)
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)
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordNestedScope
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
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.1
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-01 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord