n1_loader 1.6.3 → 1.6.4

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: c874b380de3baf4e2c0631f223261604ecb7108a4320797d746a73a90af01db5
4
- data.tar.gz: c7e98c2c4b07afbb45081b9435f9b544126378f585a23dc7419f320764af0908
3
+ metadata.gz: 7dbd6c49bba45473f2a822d02befa1ca0efdc155698648a17640c472ace4fccd
4
+ data.tar.gz: db6c04d5cc63ddbcc8a3362fba985f478601e2b5ed0f5a298df992ecdc1e8f65
5
5
  SHA512:
6
- metadata.gz: 071005e2ebc91c4884a2417d02162d795bea99813ea20b556d2b61f18d32e66ae3657f250af84ea67c32433c1d5c6697a2db9a20461d7ac0f73ff86e5b429d94
7
- data.tar.gz: 001e24c4c00ffd207229dd2721baa4424ee90bd7591d9b3ea2092d823e5bec403f51ca80d6efad7b2ff8db3bc57bb955bd04705dd97f704fc64494dffe1f8321
6
+ metadata.gz: 397c84c6ee33547838c1155c58f7488dfef34028003d7da1c26a6f9a0f2be951bfe4ff4d7df761be6185ec58e36022ead691e434af708fd74ccb2cbae503e459
7
+ data.tar.gz: 4a554a0f7aa8832b7aa81f32e8b0544baf060c0c8b59538f56e7d579b0e972e680a989ff41c7fe14c01665a7a2f8fb3883ca7ef98d60cc24005a68d3fe67bc6d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.6.4] - 2023/07/30
2
+
3
+ - Add support of `n1_optimized` ending with `?` (question mark). Thanks [Ilya Kamenko](https://github.com/Galathius) for the suggestion!
4
+
1
5
  ## [1.6.3] - 2022/12/30
2
6
 
3
7
  - Performance optimization: avoid unnecessary calls. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for the [contribution](https://github.com/djezzzl/n1_loader/pull/33).
data/README.md CHANGED
@@ -17,6 +17,12 @@ For example, it can help with resolving N+1 for:
17
17
 
18
18
  ___Support:___ ActiveRecord 5, 6, and 7.
19
19
 
20
+ Follow me and stay tuned for the updates:
21
+ - [LinkedIn](https://www.linkedin.com/in/evgeniydemin/)
22
+ - [Medium](https://evgeniydemin.medium.com/)
23
+ - [Twitter](https://twitter.com/EvgeniyDemin/)
24
+ - [GitHub](https://github.com/djezzzl)
25
+
20
26
  ## Killer feature for GraphQL API
21
27
 
22
28
  N1Loader in combination with [ArLazyPreload][6] is a killer feature for your GraphQL API.
@@ -9,7 +9,7 @@ module N1Loader
9
9
  # # with inline loader
10
10
  # n1_loader :something do
11
11
  # def perform(elements)
12
- # elements.each { |element| fulfill(element,, element.calculate_something) }
12
+ # elements.each { |element| fulfill(element, element.calculate_something) }
13
13
  # end
14
14
  # end
15
15
  #
@@ -20,15 +20,21 @@ module N1Loader
20
20
  # # custom loader
21
21
  # class MyLoader < N1Loader::Loader
22
22
  # def perform(elements)
23
- # elements.each { |element| fulfill(element,, element.calculate_something) }
23
+ # elements.each { |element| fulfill(element, element.calculate_something) }
24
24
  # end
25
25
  # end
26
26
  module Loadable
27
+ include Name
28
+
27
29
  def n1_loader(name)
30
+ name = n1_loader_name(name)
31
+
28
32
  send("#{name}_loader")
29
33
  end
30
34
 
31
35
  def n1_loader_set(name, loader_collection)
36
+ name = n1_loader_name(name)
37
+
32
38
  send("#{name}_loader=", loader_collection)
33
39
  end
34
40
 
@@ -43,11 +49,17 @@ module N1Loader
43
49
  end
44
50
 
45
51
  module ClassMethods # :nodoc:
52
+ include Name
53
+
46
54
  def n1_loader(name)
55
+ name = n1_loader_name(name)
56
+
47
57
  send("#{name}_loader")
48
58
  end
49
59
 
50
60
  def n1_loader_defined?(name)
61
+ name = n1_loader_name(name)
62
+
51
63
  respond_to?("#{name}_loader")
52
64
  end
53
65
 
@@ -63,7 +75,7 @@ module N1Loader
63
75
  class_eval(&block)
64
76
  end
65
77
  end
66
- loader_name = "#{name}_loader"
78
+ loader_name = "#{n1_loader_name(name)}_loader"
67
79
  loader_variable_name = "@#{loader_name}"
68
80
 
69
81
  n1_loaders << name
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module N1Loader
4
+ # Add support of question mark names
5
+ module Name
6
+ def n1_loader_name(name)
7
+ to_sym = name.is_a?(Symbol)
8
+
9
+ converted = name.to_s.gsub("?", "_question_mark")
10
+
11
+ to_sym ? converted.to_sym : converted
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module N1Loader
4
- VERSION = "1.6.3"
4
+ VERSION = "1.6.4"
5
5
  end
data/lib/n1_loader.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "n1_loader/version"
4
4
 
5
+ require_relative "n1_loader/core/name"
5
6
  require_relative "n1_loader/core/loader"
6
7
  require_relative "n1_loader/core/loader_collection"
7
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.6.3
4
+ version: 1.6.4
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-12-30 00:00:00.000000000 Z
11
+ date: 2023-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -196,6 +196,7 @@ files:
196
196
  - lib/n1_loader/core/loadable.rb
197
197
  - lib/n1_loader/core/loader.rb
198
198
  - lib/n1_loader/core/loader_collection.rb
199
+ - lib/n1_loader/core/name.rb
199
200
  - lib/n1_loader/core/preloader.rb
200
201
  - lib/n1_loader/version.rb
201
202
  - n1_loader.gemspec