kithe 2.12.0 → 2.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6b9d925571ed9f332f97df29a5e1f04aae7154d2c9887712cfd077f237b69eb
4
- data.tar.gz: 8a5fa5d1acd62524ec9178eecb04cc4db281bdb24d98da1e470cfdf37414f689
3
+ metadata.gz: d25b8c631517c19dd562ad64b83e8460593cade4360d4623598a883d18271e87
4
+ data.tar.gz: c1b0efd1169fff35fc0685bfb8a7db93386fe418a0d795ace01a7a1a398cfdd4
5
5
  SHA512:
6
- metadata.gz: 9b302eac83111e962398ab69ac13b6dd9a49f68b774a75615e1fbf892c2c60903c2ca640ed7c0d8a85c828c871d51772f9117247aed5d3a18f42425adc39b073
7
- data.tar.gz: 69876d680490a3989f29091b4ab06aca3671a094ea8ad6a4c2f2cf58cb6eb2882bcdf49724a8397dd72783636d61e6b72f184b846213739276bcc7e412808d87
6
+ metadata.gz: b905f4aab0f2f944551e503d0f68c2ebfc4aa527c88e9c576d6cbe1d0575c499225e856e0343fd9f2edaadf88a78d159345bba1f9b2d9de5ad56c2ae06c71158
7
+ data.tar.gz: 62e1dbfe5759afa181c2dad7522277392eb19b1013f4303e69459f6d5fda570f51d6e9b8acc8ffe2eececb4d7a79b0d558091abaf4742642d3a9bf69e253bcd9
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Kithe
2
- VERSION = '2.12.0'
2
+ VERSION = '2.13.0'
3
3
  end
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.12.0
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-01 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails