n1_loader 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/n1_loader/active_record/associations_preloader_v5.rb +2 -2
- data/lib/n1_loader/active_record/associations_preloader_v6.rb +2 -2
- data/lib/n1_loader/active_record/associations_preloader_v7.rb +2 -2
- data/lib/n1_loader/ar_lazy_preload/loadable.rb +5 -14
- data/lib/n1_loader/ar_lazy_preload.rb +1 -1
- data/lib/n1_loader/core/loadable.rb +16 -59
- data/lib/n1_loader/core/loader.rb +8 -5
- data/lib/n1_loader/core/loader_builder.rb +16 -0
- data/lib/n1_loader/core/preloader.rb +5 -8
- data/lib/n1_loader/version.rb +1 -1
- data/lib/n1_loader.rb +1 -1
- metadata +3 -37
- data/.github/workflows/rubocop.yml +0 -24
- data/.github/workflows/tests.yml +0 -66
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.rubocop.yml +0 -20
- data/CHANGELOG.md +0 -129
- data/CODE_OF_CONDUCT.md +0 -84
- data/Gemfile +0 -15
- data/LICENSE.txt +0 -21
- data/README.md +0 -276
- data/Rakefile +0 -12
- data/activerecord-gemfiles/ar_5_latest.gemfile +0 -3
- data/activerecord-gemfiles/ar_6_latest.gemfile +0 -3
- data/activerecord-gemfiles/ar_7_latest.gemfile +0 -3
- data/ar_lazy_preload-gemfiles/ar_lazy_preload_0.6.1.gemfile +0 -3
- data/ar_lazy_preload-gemfiles/ar_lazy_preload_master.gemfile +0 -3
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/examples/active_record_integration.rb +0 -33
- data/examples/ar_lazy_integration.rb +0 -36
- data/examples/ar_lazy_integration_with_isolated_loader.rb +0 -39
- data/examples/arguments_support.rb +0 -67
- data/examples/context/service.rb +0 -20
- data/examples/context/setup_ar_lazy.rb +0 -15
- data/examples/context/setup_database.rb +0 -26
- data/examples/core.rb +0 -39
- data/examples/graphql.rb +0 -63
- data/examples/isolated_loader.rb +0 -13
- data/examples/lazy_loading.rb +0 -26
- data/examples/reloading.rb +0 -32
- data/examples/shared_loader.rb +0 -34
- data/examples/single_case.rb +0 -34
- data/guides/enhanced-activerecord.md +0 -266
- data/lib/n1_loader/core/name.rb +0 -14
- data/n1_loader.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69bd23d2b22a8c7fccab4ca436c23079961fe20d5eb9eb5c9d5f9d6e9cfe6ab2
|
4
|
+
data.tar.gz: 8c7d60b0cb94207339ea697dc977d9669a5af9931b745bce889257535aaed109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340851e05310b0cfb05c9b8acd412d4bb1d06747e61e311008bd217bfead1aef6cc123bd3ca333a6bca025d0a367b2b0b4f589899438455cd9702ac6d79012c8
|
7
|
+
data.tar.gz: bdf43c35be906b011170d053ed050a60b7491087e10afde229510a10293df1d64e32a2a04d8c304611ae8a417c05568f7deda51a91b81b68820390a47dd824e7
|
@@ -24,11 +24,11 @@ module N1Loader
|
|
24
24
|
|
25
25
|
def grouped_records(association, records)
|
26
26
|
n1_load_records, records = records.partition do |record|
|
27
|
-
record.class.respond_to?(:
|
27
|
+
record.class.respond_to?(:n1_loaders) && record.class.n1_loaders.key?(association)
|
28
28
|
end
|
29
29
|
|
30
30
|
hash = n1_load_records.group_by do |record|
|
31
|
-
N1LoaderReflection.new(association, record.class.
|
31
|
+
N1LoaderReflection.new(association, record.class.n1_loaders[association])
|
32
32
|
end
|
33
33
|
|
34
34
|
hash.merge(super)
|
@@ -18,11 +18,11 @@ module N1Loader
|
|
18
18
|
|
19
19
|
def grouped_records(association, records, polymorphic_parent)
|
20
20
|
n1_load_records, records = records.partition do |record|
|
21
|
-
record.class.respond_to?(:
|
21
|
+
record.class.respond_to?(:n1_loaders) && record.class.n1_loaders[association]
|
22
22
|
end
|
23
23
|
|
24
24
|
hash = n1_load_records.group_by do |record|
|
25
|
-
N1LoaderReflection.new(association, record.class.
|
25
|
+
N1LoaderReflection.new(association, record.class.n1_loaders[association])
|
26
26
|
end
|
27
27
|
|
28
28
|
hash.merge(super)
|
@@ -18,11 +18,11 @@ module N1Loader
|
|
18
18
|
|
19
19
|
def grouped_records # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/AbcSize
|
20
20
|
n1_load_records, records = source_records.partition do |record|
|
21
|
-
record.class.respond_to?(:
|
21
|
+
record.class.respond_to?(:n1_loaders) && record.class.n1_loaders[association]
|
22
22
|
end
|
23
23
|
|
24
24
|
h = n1_load_records.group_by do |record|
|
25
|
-
N1LoaderReflection.new(association, record.class.
|
25
|
+
N1LoaderReflection.new(association, record.class.n1_loaders[association])
|
26
26
|
end
|
27
27
|
|
28
28
|
polymorphic_parent = !root? && parent.polymorphic?
|
@@ -2,22 +2,13 @@
|
|
2
2
|
|
3
3
|
module N1Loader
|
4
4
|
module ArLazyPreload
|
5
|
-
module Loadable
|
6
|
-
|
7
|
-
|
8
|
-
name, loader_name, loader_variable_name = super
|
5
|
+
module Loadable # :nodoc:
|
6
|
+
def n1_loader(name)
|
7
|
+
return n1_loaders[name] if n1_loaders[name]
|
9
8
|
|
10
|
-
|
11
|
-
loader = instance_variable_get(loader_variable_name)
|
12
|
-
return loader if loader
|
9
|
+
ContextAdapter.new(lazy_preload_context).try_preload_lazily(name) if respond_to?(:lazy_preload_context)
|
13
10
|
|
14
|
-
|
15
|
-
return instance_variable_get(loader_variable_name)
|
16
|
-
end
|
17
|
-
|
18
|
-
send("#{loader_name}_reload")
|
19
|
-
end
|
20
|
-
end
|
11
|
+
super
|
21
12
|
end
|
22
13
|
end
|
23
14
|
end
|
@@ -17,7 +17,7 @@ require_relative "ar_lazy_preload/loader_patch"
|
|
17
17
|
require_relative "ar_lazy_preload/loader"
|
18
18
|
require_relative "ar_lazy_preload/context"
|
19
19
|
|
20
|
-
N1Loader::Loadable
|
20
|
+
N1Loader::Loadable.prepend(N1Loader::ArLazyPreload::Loadable)
|
21
21
|
N1Loader::Preloader.prepend(N1Loader::ArLazyPreload::PreloaderPatch)
|
22
22
|
N1Loader::Loader.prepend(N1Loader::ArLazyPreload::LoaderPatch)
|
23
23
|
N1Loader::LoaderCollection.prepend(N1Loader::ArLazyPreload::LoaderCollectionPatch)
|
@@ -7,14 +7,14 @@ module N1Loader
|
|
7
7
|
# include N1Loader::Loadable
|
8
8
|
#
|
9
9
|
# # with inline loader
|
10
|
-
#
|
10
|
+
# n1_optimized :something do
|
11
11
|
# def perform(elements)
|
12
12
|
# elements.each { |element| fulfill(element, element.calculate_something) }
|
13
13
|
# end
|
14
14
|
# end
|
15
15
|
#
|
16
16
|
# # with custom loader
|
17
|
-
#
|
17
|
+
# n1_optimized :something, MyLoader
|
18
18
|
# end
|
19
19
|
#
|
20
20
|
# # custom loader
|
@@ -24,23 +24,21 @@ module N1Loader
|
|
24
24
|
# end
|
25
25
|
# end
|
26
26
|
module Loadable
|
27
|
-
|
27
|
+
def n1_loaders
|
28
|
+
@n1_loaders ||= {}
|
29
|
+
end
|
28
30
|
|
29
31
|
def n1_loader(name)
|
30
|
-
name
|
31
|
-
|
32
|
-
send("#{name}_loader")
|
32
|
+
n1_loaders[name]
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
name =
|
37
|
-
|
38
|
-
send("#{name}_loader=", loader_collection)
|
35
|
+
def n1_loader_reload(name)
|
36
|
+
n1_loaders[name] = LoaderCollection.new(self.class.n1_loaders[name], [self])
|
39
37
|
end
|
40
38
|
|
41
39
|
def n1_clear_cache
|
42
|
-
self.class.n1_loaders.
|
43
|
-
|
40
|
+
self.class.n1_loaders.each_key do |name|
|
41
|
+
n1_loaders[name] = nil
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -49,61 +47,20 @@ module N1Loader
|
|
49
47
|
end
|
50
48
|
|
51
49
|
module ClassMethods # :nodoc:
|
52
|
-
include Name
|
53
|
-
|
54
|
-
def n1_loader(name)
|
55
|
-
name = n1_loader_name(name)
|
56
|
-
|
57
|
-
send("#{name}_loader")
|
58
|
-
end
|
59
|
-
|
60
|
-
def n1_loader_defined?(name)
|
61
|
-
name = n1_loader_name(name)
|
62
|
-
|
63
|
-
respond_to?("#{name}_loader")
|
64
|
-
end
|
65
|
-
|
66
50
|
def n1_loaders
|
67
|
-
@n1_loaders ||= superclass.respond_to?(:n1_loaders) ? superclass.n1_loaders.dup :
|
51
|
+
@n1_loaders ||= superclass.respond_to?(:n1_loaders) ? superclass.n1_loaders.dup : {}
|
68
52
|
end
|
69
53
|
|
70
|
-
def n1_optimized(name, loader = nil, &block)
|
71
|
-
loader ||=
|
72
|
-
if block.arity == 1
|
73
|
-
define_method(:perform, &block)
|
74
|
-
else
|
75
|
-
class_eval(&block)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
loader_name = "#{n1_loader_name(name)}_loader"
|
79
|
-
loader_variable_name = "@#{loader_name}"
|
80
|
-
|
81
|
-
n1_loaders << name
|
82
|
-
|
83
|
-
define_singleton_method(loader_name) do
|
84
|
-
loader
|
85
|
-
end
|
86
|
-
|
87
|
-
define_method("#{loader_name}_reload") do
|
88
|
-
instance_variable_set(loader_variable_name,
|
89
|
-
N1Loader::LoaderCollection.new(self.class.send(loader_name), [self]))
|
90
|
-
end
|
54
|
+
def n1_optimized(name, loader = nil, &block)
|
55
|
+
loader ||= LoaderBuilder.build(&block)
|
91
56
|
|
92
|
-
|
93
|
-
instance_variable_set(loader_variable_name, loader_collection_instance)
|
94
|
-
end
|
95
|
-
|
96
|
-
define_method(loader_name) do
|
97
|
-
instance_variable_get(loader_variable_name) || send("#{loader_name}_reload")
|
98
|
-
end
|
57
|
+
n1_loaders[name] = loader
|
99
58
|
|
100
59
|
define_method(name) do |reload: false, **args|
|
101
|
-
|
60
|
+
n1_loader_reload(name) if reload || n1_loader(name).nil?
|
102
61
|
|
103
|
-
|
62
|
+
n1_loader(name).with(**args).for(self)
|
104
63
|
end
|
105
|
-
|
106
|
-
[name, loader_name, loader_variable_name]
|
107
64
|
end
|
108
65
|
end
|
109
66
|
end
|
@@ -62,11 +62,10 @@ module N1Loader
|
|
62
62
|
|
63
63
|
attr_reader :elements, :args
|
64
64
|
|
65
|
-
def check_missing_arguments!
|
65
|
+
def check_missing_arguments!
|
66
66
|
return unless (arguments = self.class.arguments)
|
67
67
|
|
68
|
-
required_arguments = arguments
|
69
|
-
.map { |argument| argument[:name] }
|
68
|
+
required_arguments = required_arguments(arguments)
|
70
69
|
|
71
70
|
return if required_arguments.all? { |argument| args.key?(argument) }
|
72
71
|
|
@@ -74,8 +73,12 @@ module N1Loader
|
|
74
73
|
|
75
74
|
list = missing_arguments.map { |argument| ":#{argument}" }.join(", ")
|
76
75
|
|
77
|
-
raise MissingArgument,
|
78
|
-
|
76
|
+
raise MissingArgument, "Loader requires [#{list}] arguments but they are missing"
|
77
|
+
end
|
78
|
+
|
79
|
+
def required_arguments(args)
|
80
|
+
args.reject { |argument| argument[:optional] }
|
81
|
+
.map { |argument| argument[:name] }
|
79
82
|
end
|
80
83
|
|
81
84
|
def check_arguments!
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module N1Loader
|
4
|
+
# The class builds {N1Loader::Loader}
|
5
|
+
class LoaderBuilder
|
6
|
+
def self.build(&block)
|
7
|
+
Class.new(N1Loader::Loader) do
|
8
|
+
if block.arity == 1
|
9
|
+
define_method(:perform, &block)
|
10
|
+
else
|
11
|
+
class_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -18,22 +18,19 @@ module N1Loader
|
|
18
18
|
keys.flatten(1).flat_map do |key|
|
19
19
|
elements
|
20
20
|
.group_by { |element| loader_class(element, key) }
|
21
|
-
.
|
22
|
-
|
23
|
-
|
21
|
+
.select { |loader_class, _| loader_class }
|
22
|
+
.map do |(loader_class, grouped_elements)|
|
24
23
|
loader_collection = N1Loader::LoaderCollection.new(loader_class, grouped_elements)
|
25
|
-
grouped_elements.each { |grouped_element| grouped_element.
|
24
|
+
grouped_elements.each { |grouped_element| grouped_element.n1_loaders[key] = loader_collection }
|
26
25
|
loader_collection
|
27
|
-
end
|
26
|
+
end
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
private
|
32
31
|
|
33
32
|
def loader_class(element, key)
|
34
|
-
element.class.respond_to?(:
|
35
|
-
element.class.n1_loader_defined?(key) &&
|
36
|
-
element.class.n1_loader(key)
|
33
|
+
element.class.respond_to?(:n1_loaders) && element.class.n1_loaders[key]
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
data/lib/n1_loader/version.rb
CHANGED
data/lib/n1_loader.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "n1_loader/version"
|
4
4
|
|
5
|
-
require_relative "n1_loader/core/
|
5
|
+
require_relative "n1_loader/core/loader_builder"
|
6
6
|
require_relative "n1_loader/core/loader"
|
7
7
|
require_relative "n1_loader/core/loader_collection"
|
8
8
|
require_relative "n1_loader/core/loadable"
|
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.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -143,39 +143,6 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
-
- ".github/workflows/rubocop.yml"
|
147
|
-
- ".github/workflows/tests.yml"
|
148
|
-
- ".gitignore"
|
149
|
-
- ".rspec"
|
150
|
-
- ".rubocop.yml"
|
151
|
-
- CHANGELOG.md
|
152
|
-
- CODE_OF_CONDUCT.md
|
153
|
-
- Gemfile
|
154
|
-
- LICENSE.txt
|
155
|
-
- README.md
|
156
|
-
- Rakefile
|
157
|
-
- activerecord-gemfiles/ar_5_latest.gemfile
|
158
|
-
- activerecord-gemfiles/ar_6_latest.gemfile
|
159
|
-
- activerecord-gemfiles/ar_7_latest.gemfile
|
160
|
-
- ar_lazy_preload-gemfiles/ar_lazy_preload_0.6.1.gemfile
|
161
|
-
- ar_lazy_preload-gemfiles/ar_lazy_preload_master.gemfile
|
162
|
-
- bin/console
|
163
|
-
- bin/setup
|
164
|
-
- examples/active_record_integration.rb
|
165
|
-
- examples/ar_lazy_integration.rb
|
166
|
-
- examples/ar_lazy_integration_with_isolated_loader.rb
|
167
|
-
- examples/arguments_support.rb
|
168
|
-
- examples/context/service.rb
|
169
|
-
- examples/context/setup_ar_lazy.rb
|
170
|
-
- examples/context/setup_database.rb
|
171
|
-
- examples/core.rb
|
172
|
-
- examples/graphql.rb
|
173
|
-
- examples/isolated_loader.rb
|
174
|
-
- examples/lazy_loading.rb
|
175
|
-
- examples/reloading.rb
|
176
|
-
- examples/shared_loader.rb
|
177
|
-
- examples/single_case.rb
|
178
|
-
- guides/enhanced-activerecord.md
|
179
146
|
- lib/n1_loader.rb
|
180
147
|
- lib/n1_loader/active_record.rb
|
181
148
|
- lib/n1_loader/active_record/associations_preloader_v5.rb
|
@@ -195,11 +162,10 @@ files:
|
|
195
162
|
- lib/n1_loader/ar_lazy_preload/preloader_patch.rb
|
196
163
|
- lib/n1_loader/core/loadable.rb
|
197
164
|
- lib/n1_loader/core/loader.rb
|
165
|
+
- lib/n1_loader/core/loader_builder.rb
|
198
166
|
- lib/n1_loader/core/loader_collection.rb
|
199
|
-
- lib/n1_loader/core/name.rb
|
200
167
|
- lib/n1_loader/core/preloader.rb
|
201
168
|
- lib/n1_loader/version.rb
|
202
|
-
- n1_loader.gemspec
|
203
169
|
homepage: https://github.com/djezzzl/n1_loader
|
204
170
|
licenses:
|
205
171
|
- MIT
|
@@ -1,24 +0,0 @@
|
|
1
|
-
name: Rubocop
|
2
|
-
|
3
|
-
on:
|
4
|
-
pull_request:
|
5
|
-
schedule:
|
6
|
-
- cron: '0 0 * * 0'
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
rubocop:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v3
|
14
|
-
|
15
|
-
- name: Set up Ruby
|
16
|
-
uses: ruby/setup-ruby@v1
|
17
|
-
with:
|
18
|
-
ruby-version: 2.7
|
19
|
-
|
20
|
-
- name: Install dependencies
|
21
|
-
run: bundle install
|
22
|
-
|
23
|
-
- name: Run Rubocop
|
24
|
-
run: bundle exec rubocop
|
data/.github/workflows/tests.yml
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
name: RSpec tests
|
2
|
-
|
3
|
-
on:
|
4
|
-
pull_request:
|
5
|
-
schedule:
|
6
|
-
- cron: '0 0 * * 0'
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
tests:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
strategy:
|
13
|
-
matrix:
|
14
|
-
ruby-version:
|
15
|
-
- '2.7'
|
16
|
-
- '3.0'
|
17
|
-
- 'head'
|
18
|
-
activerecord-gemfile:
|
19
|
-
- 'ar_5_latest'
|
20
|
-
- 'ar_6_latest'
|
21
|
-
- 'ar_7_latest'
|
22
|
-
ar_lazy_preload-gemfile:
|
23
|
-
- 'ar_lazy_preload_0.6.1'
|
24
|
-
- 'ar_lazy_preload_master'
|
25
|
-
exclude:
|
26
|
-
- ruby-version: 'head'
|
27
|
-
activerecord-gemfile: 'ar_5_latest'
|
28
|
-
|
29
|
-
- ruby-version: 'head'
|
30
|
-
activerecord-gemfile: 'ar_5_latest'
|
31
|
-
|
32
|
-
- ruby-version: '3.0'
|
33
|
-
activerecord-gemfile: 'ar_5_latest'
|
34
|
-
|
35
|
-
- ruby-version: '3.0'
|
36
|
-
activerecord-gemfile: 'ar_5_latest'
|
37
|
-
|
38
|
-
- activerecord-gemfile: 'ar_7_latest'
|
39
|
-
ar_lazy_preload-gemfile: 'ar_lazy_preload_0.6.1'
|
40
|
-
|
41
|
-
- activerecord-gemfile: 'ar_5_latest'
|
42
|
-
ar_lazy_preload-gemfile: 'ar_lazy_preload_master'
|
43
|
-
|
44
|
-
env:
|
45
|
-
ACTIVERECORD_GEMFILE: ${{ matrix.activerecord-gemfile }}
|
46
|
-
AR_LAZY_PRELOAD_GEMFILE: ${{ matrix.ar_lazy_preload-gemfile }}
|
47
|
-
|
48
|
-
steps:
|
49
|
-
- uses: actions/checkout@v3
|
50
|
-
|
51
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
52
|
-
uses: ruby/setup-ruby@v1
|
53
|
-
with:
|
54
|
-
ruby-version: ${{ matrix.ruby-version }}
|
55
|
-
|
56
|
-
- name: Install dependencies
|
57
|
-
run: bundle install
|
58
|
-
|
59
|
-
- name: Run Core tests
|
60
|
-
run: bundle exec rspec spec/n1_loader_spec.rb
|
61
|
-
|
62
|
-
- name: Run ActiveRecord tests
|
63
|
-
run: bundle exec rspec spec/n1_loader_spec.rb spec/activerecord_spec.rb
|
64
|
-
|
65
|
-
- name: Run ArLazyPreload tests
|
66
|
-
run: bundle exec rspec spec/n1_loader_spec.rb spec/activerecord_spec.rb spec/ar_lazy_preload_spec.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5
|
3
|
-
Exclude:
|
4
|
-
- examples/**/*
|
5
|
-
- vendor/bundle/**/*
|
6
|
-
|
7
|
-
Style/StringLiterals:
|
8
|
-
Enabled: true
|
9
|
-
EnforcedStyle: double_quotes
|
10
|
-
|
11
|
-
Style/StringLiteralsInInterpolation:
|
12
|
-
Enabled: true
|
13
|
-
EnforcedStyle: double_quotes
|
14
|
-
|
15
|
-
Layout/LineLength:
|
16
|
-
Max: 120
|
17
|
-
|
18
|
-
Metrics/BlockLength:
|
19
|
-
Exclude:
|
20
|
-
- spec/**/*
|
data/CHANGELOG.md
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
## [1.7.1] - 2023/07/30
|
2
|
-
|
3
|
-
- Fix interface discrepancy for `N1LoaderReflection`. Thanks [Denis Talakevich](https://github.com/senid231) for suggesting it!
|
4
|
-
|
5
|
-
## [1.7.0] - 2023/07/30
|
6
|
-
|
7
|
-
Extend the flexibility of loading data comparison. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for suggesting it!
|
8
|
-
|
9
|
-
**BREAKING CHANGES:**
|
10
|
-
|
11
|
-
Loose comparison of loaded data. Before loaded data was initialized with identity comparator in mind:
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
@loaded = {}.compare_by_identity
|
15
|
-
```
|
16
|
-
|
17
|
-
Now it will be:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
@loaded = {}
|
21
|
-
```
|
22
|
-
|
23
|
-
This might bring unwanted results for cases when strict comparison was wanted.
|
24
|
-
|
25
|
-
On the other hand, it gives more flexibility for many other cases, especially with isolated loader.
|
26
|
-
For example, this will work now, when it wasn't working before.
|
27
|
-
|
28
|
-
```ruby
|
29
|
-
# ActiveRecord object
|
30
|
-
object = Entity.first
|
31
|
-
|
32
|
-
# Initialize isolated loader
|
33
|
-
instance = loader.new([object])
|
34
|
-
|
35
|
-
# This was working before because the loaded object is identical to passed object by `#object_id`
|
36
|
-
instance.for(object)
|
37
|
-
|
38
|
-
# This wasn't working before because the loaded object is not identical to passed one by `#object_id`
|
39
|
-
#
|
40
|
-
# But it will be working now, because object == Entity.find(object.id)
|
41
|
-
instance.for(Entity.find(object.id))
|
42
|
-
```
|
43
|
-
|
44
|
-
If you need strict comparison support, please feel free to open the issue or the PR.
|
45
|
-
|
46
|
-
## [1.6.6] - 2023/07/30
|
47
|
-
|
48
|
-
- Fix naive check of required arguments. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for the issue!
|
49
|
-
|
50
|
-
## [1.6.5] - 2023/07/30
|
51
|
-
|
52
|
-
- Fix nested preloading for ActiveRecord 7. Thanks [Igor Gonchar](https://github.com/gigorok) for the issue!
|
53
|
-
|
54
|
-
## [1.6.4] - 2023/07/30
|
55
|
-
|
56
|
-
- Add support of `n1_optimized` ending with `?` (question mark). Thanks [Ilya Kamenko](https://github.com/Galathius) for the suggestion!
|
57
|
-
|
58
|
-
## [1.6.3] - 2022/12/30
|
59
|
-
|
60
|
-
- Performance optimization: avoid unnecessary calls. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for the [contribution](https://github.com/djezzzl/n1_loader/pull/33).
|
61
|
-
|
62
|
-
## [1.6.2] - 2022/11/23
|
63
|
-
|
64
|
-
- Add fund metadata
|
65
|
-
|
66
|
-
## [1.6.1] - 2022/10/29
|
67
|
-
|
68
|
-
- Fix ArLazyPreload context setup when using isolated loaders for objects without the context.
|
69
|
-
|
70
|
-
## [1.6.0] - 2022/10/24
|
71
|
-
|
72
|
-
- Add support of ArLazyPreload context for isolated loaders.
|
73
|
-
|
74
|
-
## [1.5.1] - 2022/09/20
|
75
|
-
|
76
|
-
- Fix support of falsey value of arguments. Thanks [Aitor Lopez Beltran](https://github.com/aitorlb) for the [contribution](https://github.com/djezzzl/n1_loader/pull/23)!
|
77
|
-
|
78
|
-
## [1.5.0] - 2022/05/01
|
79
|
-
|
80
|
-
- Add support of Rails 7
|
81
|
-
|
82
|
-
## [1.4.4] - 2022/04/29
|
83
|
-
|
84
|
-
- Inject `N1Loader::Loadable` to `ActiveRecord::Base` automatically
|
85
|
-
- Make `reload` to call `n1_clear_cache`
|
86
|
-
|
87
|
-
## [1.4.3] - 2022-04-13
|
88
|
-
|
89
|
-
- Add `default` support to arguments
|
90
|
-
|
91
|
-
## [1.4.2] - 2022-03-01
|
92
|
-
|
93
|
-
- Add n1_clear_cache method which is useful for cases like reload in ActiveRecord
|
94
|
-
|
95
|
-
## [1.4.1] - 2022-02-24
|
96
|
-
|
97
|
-
- Fix preloading of invalid objects
|
98
|
-
|
99
|
-
## [1.4.0] - 2022-02-22
|
100
|
-
|
101
|
-
- add support of optional arguments
|
102
|
-
|
103
|
-
BREAKING CHANGES:
|
104
|
-
- rework arguments to use single definition through `argument <name>` only
|
105
|
-
- use keyword arguments
|
106
|
-
|
107
|
-
## [1.3.0] - 2022-02-22
|
108
|
-
|
109
|
-
- add support of named arguments with `argument <name>`
|
110
|
-
|
111
|
-
BREAKING CHANGES:
|
112
|
-
- rename `n1_load` to `n1_optimized`
|
113
|
-
- rework `def self.arguments_key` to `cache_key`
|
114
|
-
|
115
|
-
## [1.2.0] - 2022-01-14
|
116
|
-
|
117
|
-
- Introduce arguments support.
|
118
|
-
|
119
|
-
## [1.1.0] - 2021-12-27
|
120
|
-
|
121
|
-
- Introduce `fulfill` method to abstract the storage.
|
122
|
-
|
123
|
-
## [1.0.0] - 2021-12-26
|
124
|
-
|
125
|
-
- Various of great features.
|
126
|
-
|
127
|
-
## [0.1.0] - 2021-12-16
|
128
|
-
|
129
|
-
- Initial release.
|