miscellany 0.1.5 → 0.1.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c746bac8225f832908693a4c5ec79af44fc936ea6a91457cd7b22e10d33114a4
|
4
|
+
data.tar.gz: 674c97648f5bda39bbc6a2025fdd35e103c6e0dbad56ef72a5e912dee15e6119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc8bea4728c5e04209cedaedd7d16a93b3e59fcc08ae52c4bffde09dc2f06be85dc03fafff6f406c2f04078bf6f71bd773e924d687d8046f6c4597b9f1e17c6e
|
7
|
+
data.tar.gz: efb98108c92e1047d70f96bd591893119b90c6a8cb9b5b3314258063d28313c785464a16def6f1b877a480f38527f0d0f6fa1ae5029854591cb8ea19441cfad2
|
@@ -32,7 +32,7 @@ module Miscellany
|
|
32
32
|
def bulk_destroy_internal(items, **kwargs)
|
33
33
|
options = {}
|
34
34
|
options.merge!(kwargs)
|
35
|
-
ClassCallbackExector.run_callbacks(model_class, :bulk_destroy, options: options) do
|
35
|
+
ClassCallbackExector.run_callbacks(model_class, :bulk_destroy, { options: options }) do
|
36
36
|
if items.respond_to?(:find_in_batches)
|
37
37
|
items.find_in_batches do |batch|
|
38
38
|
_destroy_batch(batch, options)
|
@@ -47,6 +47,7 @@ module Miscellany
|
|
47
47
|
ClassCallbackExector.run_callbacks(model_class, :destroy_batch, {
|
48
48
|
model_class: model_class,
|
49
49
|
batch: batch,
|
50
|
+
options: options,
|
50
51
|
}) do
|
51
52
|
model_class.destroy_bulk_batch(batch, options)
|
52
53
|
end
|
@@ -84,7 +85,6 @@ module Miscellany
|
|
84
85
|
env[k]
|
85
86
|
end
|
86
87
|
end
|
87
|
-
@options = options
|
88
88
|
end
|
89
89
|
|
90
90
|
def self.run_callbacks(cls, callback, env={}, &blk)
|
@@ -35,14 +35,15 @@ module Miscellany
|
|
35
35
|
comp = model.get_defined_computed(k)
|
36
36
|
raise "Undefined ComputedColum :#{k}" if comp.nil?
|
37
37
|
|
38
|
-
builder = ComputedBuilder.new(k, v, &comp)
|
38
|
+
builder = ComputedBuilder.new(all, k, v, &comp)
|
39
39
|
builder.apply(query)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
class ComputedBuilder
|
45
|
-
def initialize(key, args, &blk)
|
45
|
+
def initialize(relation, key, args, &blk)
|
46
|
+
@relation = relation
|
46
47
|
@key = key
|
47
48
|
@args = args.is_a?(Array) ? args : [args]
|
48
49
|
@block = blk
|
@@ -55,7 +56,7 @@ module Miscellany
|
|
55
56
|
raise "Must provide either a value or a block" if arg == :not_given && !blk
|
56
57
|
|
57
58
|
if arg == :not_given
|
58
|
-
arg = blk
|
59
|
+
arg = @relation.instance_eval(&blk)
|
59
60
|
end
|
60
61
|
|
61
62
|
@compiled[m] = arg
|
@@ -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
|
data/lib/miscellany/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan Knapp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|