uberloader 0.2.0 → 0.4.0
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/README.md +33 -21
- data/lib/uberloader/preloader/v8.rb +9 -0
- data/lib/uberloader/version.rb +1 -1
- data/lib/uberloader.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf39d2fc30a38dc13e238ddfc6d8d2e4bb47c6d2a3e94da375dcf328055f4ba4
|
|
4
|
+
data.tar.gz: c761f0bb0e277ae12781066a3ad16c9e06a049ca303966b3c0d97040d7144eb5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 646a47d968675f8f6e156e56865187dfecc52c64cda7c86244737b515c5f2e2a15992a2678cc11d8e0cfec7fbf49dc508c2739d428238a642d90bc396a27a11f
|
|
7
|
+
data.tar.gz: fb8417d185f513eb3a31253a52301767cd3e08f73e9eb6faee7c8566f26f395e21e8b94c54a8b96432bd4a359a0dee9d8247ff1439456e3a6566683ba8f6f1d6
|
data/README.md
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
1
|
# Uberloader
|
|
2
2
|
|
|
3
|
-
Uberloader is a new way of preloading associations in ActiveRecord. It
|
|
3
|
+
Uberloader is a new way of preloading associations in ActiveRecord. It behaves like `preload`, but with a lot more power.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
#### Install with Bundler
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bundle add uberloader
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
#### Nested preloads use blocks
|
|
7
12
|
|
|
8
13
|
```ruby
|
|
9
14
|
widgets = Widget
|
|
10
15
|
.where(category_id: category_ids)
|
|
11
|
-
# Preload category
|
|
12
16
|
.uberload(:category)
|
|
13
|
-
|
|
14
|
-
.uberload(:parts, scope: Part.order(:name)) do |u|
|
|
15
|
-
# Preload the parts' manufacturer
|
|
17
|
+
.uberload(:parts) { |u|
|
|
16
18
|
u.uberload(:manufacturer)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
u.scope my_subparts_scope_helper
|
|
20
|
-
u.scope Subpart.where(kind: params[:sub_kinds]) if params[:sub_kinds]&.any?
|
|
21
|
-
|
|
22
|
-
u.uberload(:foo) do
|
|
19
|
+
u.uberload(:subparts) {
|
|
20
|
+
u.uberload(:foo) {
|
|
23
21
|
u.uberload(:bar)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
27
25
|
```
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
#### Why? So you can customize preload scopes
|
|
30
28
|
|
|
31
|
-
```
|
|
32
|
-
|
|
29
|
+
```ruby
|
|
30
|
+
widgets = Widget
|
|
31
|
+
.where(category_id: category_ids)
|
|
32
|
+
.uberload(:category)
|
|
33
|
+
# specify scope using an argument
|
|
34
|
+
.uberload(:parts, scope: Part.order(:name)) { |u|
|
|
35
|
+
u.uberload(:manufacturer)
|
|
36
|
+
u.uberload(:subparts) {
|
|
37
|
+
# or using the #scope method
|
|
38
|
+
u.scope my_subparts_scope_helper
|
|
39
|
+
u.scope Subpart.where(kind: params[:sub_kinds]) if params[:sub_kinds]&.any?
|
|
40
|
+
|
|
41
|
+
u.uberload(:foo) {
|
|
42
|
+
u.uberload(:bar)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
33
46
|
```
|
|
34
47
|
|
|
35
48
|
## Interaction with preload and includes
|
|
@@ -48,7 +61,7 @@ Regretably, none of this is possible without monkeypatching `ActiveRecord::Relat
|
|
|
48
61
|
|
|
49
62
|
To assess its stability over time, I ran Uberloader's unit tests against the full matrix of (supported) ActiveRecord and Uberloader versions. They passed consistently, but with predictable clusters of failures around pre-release and X.0.0 versions.
|
|
50
63
|
|
|
51
|
-
I will keep these tests running
|
|
64
|
+
I will keep these tests running regularly. [You can find the link to the results here](https://github.com/jhollinger/uberloader/blob/docs/VERSION_COMPATIBILITY.md). If something breaks, I'll try to fix it. If we're lucky, maybe this behavior could get _into_ Rails itself someday...
|
|
52
65
|
|
|
53
66
|
## Testing
|
|
54
67
|
|
|
@@ -88,5 +101,4 @@ bin/generate-version-test-table
|
|
|
88
101
|
# Run tests for specific versions
|
|
89
102
|
# Appraisal ActiveRecord Uberloader
|
|
90
103
|
bin/test-compatibility 7.1 7.1.3.2 0.1.0
|
|
91
|
-
bin/test-compatibility 7.1 7.1.3.2 HEAD
|
|
92
104
|
```
|
data/lib/uberloader/version.rb
CHANGED
data/lib/uberloader.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uberloader
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jordan Hollinger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: '6.0'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '9.0'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: '6.0'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '9.0'
|
|
33
33
|
description: Customizable SQL when preloading in ActiveRecord
|
|
34
34
|
email: jordan.hollinger@gmail.com
|
|
35
35
|
executables: []
|
|
@@ -42,6 +42,7 @@ files:
|
|
|
42
42
|
- lib/uberloader/context.rb
|
|
43
43
|
- lib/uberloader/preloader/v6.rb
|
|
44
44
|
- lib/uberloader/preloader/v7.rb
|
|
45
|
+
- lib/uberloader/preloader/v8.rb
|
|
45
46
|
- lib/uberloader/query_methods.rb
|
|
46
47
|
- lib/uberloader/uberload.rb
|
|
47
48
|
- lib/uberloader/version.rb
|
|
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
65
|
- !ruby/object:Gem::Version
|
|
65
66
|
version: '0'
|
|
66
67
|
requirements: []
|
|
67
|
-
rubygems_version: 3.
|
|
68
|
+
rubygems_version: 3.5.22
|
|
68
69
|
signing_key:
|
|
69
70
|
specification_version: 4
|
|
70
71
|
summary: Advanced preloading for ActiveRecord
|