occams-record 0.23.0 → 0.24.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 +3 -1
- data/lib/occams-record/eager_loaders/ad_hoc_base.rb +1 -1
- data/lib/occams-record/eager_loaders.rb +6 -4
- data/lib/occams-record/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 707ed6c9bf173cd193bb01d26149eb78acc2908e352af3eb863c483c357e6a5e
|
4
|
+
data.tar.gz: 257c5d00ececf487537d599103d1f60b9adede4e1411e1e82f0c66e01210bfb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac390d24a51ed24ba8cf941bae278bf0756c55724fd1b17f496b56ad11aae74873677cc698c78d44bb39a976e241a42c3f2879df8b29d6125ade39eed9ed83df
|
7
|
+
data.tar.gz: c416b257ff7d5d95aea4bb195b56009e912fd93d4127d77fc68c2d3d5ca28ed6e84f99b1a959410cb39a7273927394bb10eba6a97dffa116af74a75b9078b8b2
|
data/README.md
CHANGED
@@ -31,6 +31,8 @@ gem 'occams-record'
|
|
31
31
|
|
32
32
|
**Simple example**
|
33
33
|
|
34
|
+
Build your query the same as before, using `ActiveRecord`'s excellent query builder. Just hand it off to `OccamsRecord.query` before running it. Be sure to use `OccamsRecord`'s eager loading helpers instead of `ActiveRecord`'s.
|
35
|
+
|
34
36
|
```ruby
|
35
37
|
widgets = OccamsRecord.
|
36
38
|
query(Widget.order("name")).
|
@@ -65,7 +67,7 @@ widgets[1].splines.map { |s| s.description }
|
|
65
67
|
=> ["Spline 4", "Spline 5"]
|
66
68
|
```
|
67
69
|
|
68
|
-
**
|
70
|
+
**Even more complicated example**
|
69
71
|
|
70
72
|
Here we're eager loading several levels down. Notice the `Proc` given to `eager_load(:orders)`. The `select:` option is just for convenience; you may instead pass a `Proc` and customize the query with any of ActiveRecord's query builder helpers (`select`, `where`, `order`, `limit`, etc).
|
71
73
|
|
@@ -16,7 +16,7 @@ module OccamsRecord
|
|
16
16
|
# @param binds [Hash] any additional binds for your query.
|
17
17
|
# @param model [ActiveRecord::Base] optional - ActiveRecord model that represents what you're loading. required when using Sqlite.
|
18
18
|
# @param use [Array<Module>] optional - Ruby modules to include in the result objects (single or array)
|
19
|
-
# @yield
|
19
|
+
# @yield eager load associations nested under this one
|
20
20
|
#
|
21
21
|
def initialize(name, mapping, sql, binds: {}, model: nil, use: nil, &eval_block)
|
22
22
|
@name = name.to_s
|
@@ -62,9 +62,10 @@ module OccamsRecord
|
|
62
62
|
# @param binds [Hash] any additional binds for your query.
|
63
63
|
# @param model [ActiveRecord::Base] optional - ActiveRecord model that represents what you're loading. required when using Sqlite.
|
64
64
|
# @param use [Array<Module>] optional - Ruby modules to include in the result objects (single or array)
|
65
|
+
# @yield eager load associations nested under this one
|
65
66
|
#
|
66
|
-
def eager_load_one(
|
67
|
-
@eager_loaders << EagerLoaders::AdHocOne.new(
|
67
|
+
def eager_load_one(name, mapping, sql, binds: {}, model: nil, use: nil, &eval_block)
|
68
|
+
@eager_loaders << EagerLoaders::AdHocOne.new(name, mapping, sql, binds: binds, model: model, use: use, &eval_block)
|
68
69
|
self
|
69
70
|
end
|
70
71
|
|
@@ -92,9 +93,10 @@ module OccamsRecord
|
|
92
93
|
# @param use [Array<Module>] optional - Ruby modules to include in the result objects (single or array)
|
93
94
|
# @param binds [Hash] any additional binds for your query.
|
94
95
|
# @param model [ActiveRecord::Base] optional - ActiveRecord model that represents what you're loading. required when using Sqlite.
|
96
|
+
# @yield eager load associations nested under this one
|
95
97
|
#
|
96
|
-
def eager_load_many(
|
97
|
-
@eager_loaders << EagerLoaders::AdHocMany.new(
|
98
|
+
def eager_load_many(name, mapping, sql, binds: {}, model: nil, use: nil, &eval_block)
|
99
|
+
@eager_loaders << EagerLoaders::AdHocMany.new(name, mapping, sql, binds: binds, model: model, use: use, &eval_block)
|
98
100
|
self
|
99
101
|
end
|
100
102
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occams-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.3'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.3'
|
33
33
|
description: A faster, lower-memory querying API for ActiveRecord that returns results
|
34
34
|
as unadorned, read-only objects.
|
35
35
|
email: jordan.hollinger@gmail.com
|