n1_loader 1.4.0 → 1.4.1

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
  SHA256:
3
- metadata.gz: 2d0f96166ae91c856012ea26c933cc56c7d33f68065b753a18adc3c6b9da7e87
4
- data.tar.gz: adccc88c382d9283c2af9b41059298fa15563e47615678ef20629a0183a51253
3
+ metadata.gz: fc06934b6c230d9b48dce18c7e9ee49afad4ab32d51d4550eb3e2916fe977656
4
+ data.tar.gz: 456575999736bba2b4b8f33ff02a4908a7705b2cc31875bca9c80f3dbeeb4125
5
5
  SHA512:
6
- metadata.gz: ad3b1273627cf7abb5922cc7139c34e5e9543dc91d296d7e44deea690367d32082dd1ddc028ba40a4ed7fa402a65eb8f5aed36b6d8df0436937e59aaa6cef65a
7
- data.tar.gz: fde03e325f2b780a070786f1648a98d278933c84b3266cedf4db50cd268b029839ff06290416846a9ab2a85a25a0795c30684845e4da15909417389dbd1a7a82
6
+ metadata.gz: 4640cffcc0fe6e03672ba46fc16e9fc29fc33d1c18b6d9e54e4c6026cd0d0b465846a60e0b75ab0dec46fd4db21ae914a0f92d3cc4623e622b4782094d6ce680
7
+ data.tar.gz: a010ffac1ce7604ce9434de734fa20f0e5162ff7307f6ddcafe0b9be1119a4f37d3774b7dd4beb8d36affd56e4f30830d01904406ce1f2b2fc2989d7f9910fa1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.4.1] - 2022-02-24
2
+
3
+ - Fix preloading of invalid objects
4
+
1
5
  ## [1.4.0] - 2022-02-22
2
6
 
3
7
  - add support of optional arguments
@@ -17,13 +17,23 @@ module N1Loader
17
17
  def preload(*keys)
18
18
  keys.flatten(1).flat_map do |key|
19
19
  elements
20
- .group_by { |element| element.class.n1_loader(key) }
20
+ .group_by { |element| loader_class(element, key) }
21
21
  .map do |loader_class, grouped_elements|
22
+ next unless loader_class
23
+
22
24
  loader_collection = N1Loader::LoaderCollection.new(loader_class, grouped_elements)
23
25
  grouped_elements.each { |grouped_element| grouped_element.n1_loader_set(key, loader_collection) }
24
26
  loader_collection
25
- end
27
+ end.compact
26
28
  end
27
29
  end
30
+
31
+ private
32
+
33
+ def loader_class(element, key)
34
+ element.class.respond_to?(:n1_loader_defined?) &&
35
+ element.class.n1_loader_defined?(key) &&
36
+ element.class.n1_loader(key)
37
+ end
28
38
  end
29
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module N1Loader
4
- VERSION = "1.4.0"
4
+ VERSION = "1.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n1_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-22 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord