miscellany 0.1.7 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e57424c3b049c0f32faf8cf0a7e0f7f85145de07dc8ac09e61b2c2c3b8dd926
4
- data.tar.gz: 52c108a746be070473df4bc9c4bad66daf216809e72dea58a628b2c94d14923d
3
+ metadata.gz: 5951bc4a5a92a69c804727cd9e08c9059a3a28471ba86250407f4d791ef95815
4
+ data.tar.gz: d976b84948bd3427e533c79bccc5d76731bb66c5ecb67658cd3cd23b8b4b1667
5
5
  SHA512:
6
- metadata.gz: e9d8ddae9f677caa1c1c689a85abefaa64beb46cac97e9005be62c68b709ebe02bfb26791344bb58ab13cf6a557024d12bd8cbe667e88097c466cacf5148b31e
7
- data.tar.gz: a8fe4f104a46d80c2af4fb0421716d34359fb0fabf35cb362b4ed33e284ee20a09054ec12fa14340127cadbf57c21e2982f6ed89459de54b7bf576eca395b501
6
+ metadata.gz: '0928268e504805adf73331fd43a760c45f0edbe36d6a1d5b3755d3b625806a31df5b1e5eb4fcc354bdfce69e1f5db135b1a346124b8f453bf56cd732072ff582'
7
+ data.tar.gz: fadada2364e7bff52b7a00899fb814e1b0458753f3a62a05824d885cbae9d01338fe2bb484ea2e2e8b96f275f9846e5bbbc4ebacfeb25e5970b1136e54e4f91a
@@ -0,0 +1,20 @@
1
+ module Miscellany
2
+ module GoldiloadValue
3
+
4
+ def goldiload_value(key, &blk)
5
+ return goldi_values[key] if goldi_values && goldi_values.key?(key)
6
+
7
+ models = auto_include_context.models
8
+ loaded = blk.call(models)
9
+ models.each do |m|
10
+ (m.goldi_values ||= {})[key] = loaded.key?(m) ? loaded[m] : loaded[m&.id]
11
+ end
12
+
13
+ goldi_values[key]
14
+ end
15
+
16
+ def self.install
17
+ ::ActiveRecord::Base.include(GoldiloadValue)
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Miscellany
2
- VERSION = "0.1.7".freeze
2
+ VERSION = "0.1.9".freeze
3
3
  end
data/lib/miscellany.rb CHANGED
@@ -14,5 +14,6 @@ module Miscellany
14
14
  Miscellany::CustomPreloaders.install
15
15
  Miscellany::ArbitraryPrefetch.install
16
16
  Miscellany::ComputedColumns.install
17
+ Miscellany::GoldiloadValue.install
17
18
  end
18
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miscellany
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Knapp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
11
+ date: 2023-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -115,6 +115,7 @@ files:
115
115
  - lib/miscellany/active_record/batched_destruction.rb
116
116
  - lib/miscellany/active_record/computed_columns.rb
117
117
  - lib/miscellany/active_record/custom_preloaders.rb
118
+ - lib/miscellany/active_record/goldiload_value.rb
118
119
  - lib/miscellany/batch_processor.rb
119
120
  - lib/miscellany/batching_csv_processor.rb
120
121
  - lib/miscellany/controller/http_error_handling.rb