ar_lazy_preload 1.1.2 → 2.0.0

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: 5c0652f697df796459ee3750a5a5e54d94bbc1539f0a330f06c24a507f14004e
4
- data.tar.gz: ca559bf8f481486ce7fadf75c0e0fa2e2ec1d25babdb1dee590fecbc117c5d3c
3
+ metadata.gz: 3f8b5858ee6bbfd4ba3db6c61f5577ef7651c06b63bb4c38ddc5dad7a61dba2d
4
+ data.tar.gz: 1087cc1b4e487d6a6a404e3def90ee9dc3baf9b1c143b5a58176dbd27d206f40
5
5
  SHA512:
6
- metadata.gz: c3a2bc64e535ff7ba87fa57b568414c87b24ce358bd6587128bfc7d153d055a9187b8162964639d72adf53b22f92fe22970c5a906ce891054161cea5a9e754f2
7
- data.tar.gz: aef7c0d8d88f8fea6de1f81abc89baa9aa2fa5fed2b74a9d3eb16e21cd057efacc735c8d46406c54cd4bf3c2e3ac3fed025b95e2a3e9c7188554eff2a6afe442
6
+ metadata.gz: cd0d2df79afe940662c1cab747c0fa1e8d2dab46eaba585663a2441c0f1058bd56d355e16d1feba4a46af52fe81167133c0e1e42dc3e31212b702310e57d2f92
7
+ data.tar.gz: 2398c417a95f0c1472b677647e74f5bbdd02c5c426f7d41b583d33557122642dbd0925feeb7ca62bbb36ad5ba5c934280e7e10d3898a3b4e9f8c4ac5c8e02c32
data/README.md CHANGED
@@ -7,6 +7,12 @@
7
7
  - **Perfect fit for GraphQL**. Define a list of associations to load at the top-level resolver and let the gem do its job
8
8
  - **Auto-preload support**. If you don't want to specify the association list–set `ArLazyPreload.config.auto_preload` to `true`
9
9
 
10
+ Used in production by:
11
+
12
+ - [Fund that flip](https://evilmartians.com/chronicles/big-refactoring-fix-that-app-for-fund-that-flip)
13
+ - Toptal
14
+ - _Want to be here? Let me know_ 🙂
15
+
10
16
  ## Why should I use it?
11
17
 
12
18
  Lazy loading is super helpful when the list of associations to load is determined dynamically. For instance, in GraphQL this list comes from the API client, and you'll have to inspect the selection set to find out what associations are going to be used.
@@ -1,32 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "ar_lazy_preload/active_record/base"
4
- require "ar_lazy_preload/active_record/relation"
5
- require "ar_lazy_preload/active_record/association"
6
- require "ar_lazy_preload/active_record/collection_association"
7
- require "ar_lazy_preload/active_record/merger"
8
- require "ar_lazy_preload/active_record/association_relation"
9
- require "ar_lazy_preload/active_record/collection_proxy"
10
-
11
3
  module ArLazyPreload
12
4
  class Railtie < Rails::Railtie
13
5
  config.to_prepare do |_app|
14
6
  ActiveSupport.on_load(:active_record) do
15
- ActiveRecord::Base.include(Base)
16
-
17
- ActiveRecord::Relation.prepend(Relation)
18
- ActiveRecord::AssociationRelation.prepend(AssociationRelation)
19
- ActiveRecord::Relation::Merger.prepend(Merger)
20
-
21
- [
22
- ActiveRecord::Associations::CollectionAssociation,
23
- ActiveRecord::Associations::Association
24
- ].each { |klass| klass.prepend(Association) }
25
-
26
- ActiveRecord::Associations::CollectionAssociation.prepend(CollectionAssociation)
27
- ActiveRecord::Associations::CollectionProxy.prepend(CollectionProxy)
28
-
29
- ArLazyPreload::Preloader.patch_for_rails_7! if ActiveRecord::VERSION::MAJOR >= 7
7
+ ArLazyPreload.install_hooks
30
8
  end
31
9
  end
32
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArLazyPreload
4
- VERSION = "1.1.2"
4
+ VERSION = "2.0.0"
5
5
  end
@@ -1,12 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "ar_lazy_preload/configuration"
4
- require "ar_lazy_preload/railtie"
4
+ require "ar_lazy_preload/railtie" if defined?(::Rails)
5
+
6
+ require "ar_lazy_preload/active_record/base"
7
+ require "ar_lazy_preload/active_record/relation"
8
+ require "ar_lazy_preload/active_record/association"
9
+ require "ar_lazy_preload/active_record/collection_association"
10
+ require "ar_lazy_preload/active_record/merger"
11
+ require "ar_lazy_preload/active_record/association_relation"
12
+ require "ar_lazy_preload/active_record/collection_proxy"
5
13
 
6
14
  module ArLazyPreload
7
15
  class << self
8
16
  def config
9
17
  @config ||= Configuration.new
10
18
  end
19
+
20
+ def install_hooks
21
+ ActiveRecord::Base.include(Base)
22
+
23
+ ActiveRecord::Relation.prepend(Relation)
24
+ ActiveRecord::AssociationRelation.prepend(AssociationRelation)
25
+ ActiveRecord::Relation::Merger.prepend(Merger)
26
+
27
+ ActiveRecord::Associations::CollectionAssociation.prepend(Association)
28
+ ActiveRecord::Associations::Association.prepend(Association)
29
+
30
+ ActiveRecord::Associations::CollectionAssociation.prepend(CollectionAssociation)
31
+ ActiveRecord::Associations::CollectionProxy.prepend(CollectionProxy)
32
+
33
+ ArLazyPreload::Preloader.patch_for_rails_7! if ActiveRecord::VERSION::MAJOR >= 7
34
+ end
11
35
  end
12
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_lazy_preload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-05 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
20
- type: :runtime
19
+ version: '6.0'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.2'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
220
  requirements:
221
221
  - - ">="
222
222
  - !ruby/object:Gem::Version
223
- version: '2.6'
223
+ version: '2.7'
224
224
  required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - ">="