kithe 2.12.0 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/kithe/model.rb +41 -0
- data/lib/kithe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d25b8c631517c19dd562ad64b83e8460593cade4360d4623598a883d18271e87
|
4
|
+
data.tar.gz: c1b0efd1169fff35fc0685bfb8a7db93386fe418a0d795ace01a7a1a398cfdd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b905f4aab0f2f944551e503d0f68c2ebfc4aa527c88e9c576d6cbe1d0575c499225e856e0343fd9f2edaadf88a78d159345bba1f9b2d9de5ad56c2ae06c71158
|
7
|
+
data.tar.gz: 62e1dbfe5759afa181c2dad7522277392eb19b1013f4303e69459f6d5fda570f51d6e9b8acc8ffe2eececb4d7a79b0d558091abaf4742642d3a9bf69e253bcd9
|
data/app/models/kithe/model.rb
CHANGED
@@ -27,6 +27,13 @@ class Kithe::Model < ActiveRecord::Base
|
|
27
27
|
|
28
28
|
attr_json_config(default_accepts_nested_attributes: { reject_if: :all_blank })
|
29
29
|
|
30
|
+
# keep json_attributes column out of #inspect display of model shown in logs and
|
31
|
+
# console -- because it can be huge, and is generally duplicated by individual
|
32
|
+
# attributes already included. filter_attributes only supported in Rails 6+
|
33
|
+
if self.respond_to?(:filter_attributes)
|
34
|
+
self.filter_attributes += [:json_attributes]
|
35
|
+
end
|
36
|
+
|
30
37
|
validates_presence_of :title
|
31
38
|
|
32
39
|
# this should only apply to Works, but we define it here so we can preload it
|
@@ -147,6 +154,40 @@ class Kithe::Model < ActiveRecord::Base
|
|
147
154
|
self.leaf_representative_id = result
|
148
155
|
end
|
149
156
|
|
157
|
+
# Insert an after_commit hook that will run BEFORE any existing after_commit hooks,
|
158
|
+
# regardless of Rails version and run_after_transaction_callbacks_in_order_defined configuration.
|
159
|
+
#
|
160
|
+
# Sometimes you need to insert an after_commit hook that goes BEFORE shrine's after_commit
|
161
|
+
# callbacks for promotion in activerecord after_commit
|
162
|
+
#
|
163
|
+
# In Rails prior to 7.1, that happens automatically just by adding an after_commit.
|
164
|
+
# But Rails 7.1 by default changes the order of after_commit AND removes the ability
|
165
|
+
# to alter it with prepend! https://github.com/rails/rails/issues/50118
|
166
|
+
#
|
167
|
+
# We add this method, that will do the right thing -- making sure the new hook we are adding
|
168
|
+
# is run BEFORE any existing ones -- in both Rails < 7.1 and Rails 7.1 with
|
169
|
+
# run_after_transaction_callbacks_in_order_defined
|
170
|
+
#
|
171
|
+
# @example
|
172
|
+
#
|
173
|
+
# class MyAsset < Kithe::Asset
|
174
|
+
# kithe_earlier_after_commit :some_method_to_run_first
|
175
|
+
#
|
176
|
+
# kithe_earlier_after_commit do
|
177
|
+
# # This code will be in an after_commit that comes BEFORE
|
178
|
+
# # any existing ones
|
179
|
+
# end
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
def self.kithe_earlier_after_commit(*args, &block)
|
183
|
+
# confusingly in this state, we need prepend FALSE to have this new callback be registered to go
|
184
|
+
# FIRST. And this actually is correct and works whether or not run_after_transaction_callbacks_in_order_defined
|
185
|
+
# Very confusing, we test thorougly.
|
186
|
+
set_options_for_callbacks!(args, {prepend: false})
|
187
|
+
|
188
|
+
set_callback(:commit, :after, *args, &block)
|
189
|
+
end
|
190
|
+
|
150
191
|
private
|
151
192
|
|
152
193
|
|
data/lib/kithe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kithe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|