Module: Shrine::Plugins::KithePromotionCallbacks::AttacherMethods
- Defined in:
- lib/shrine/plugins/kithe_promotion_callbacks.rb
Instance Method Summary collapse
-
#activerecord_after_save ⇒ Object
For INLINE promotion, we need to wrap this one in callbacks, in order to be wrapping enough to a) be able to cancel in ‘before`, and b) have `after` actually be running after promotion is complete and persisted.
-
#atomic_promote(*args, **kwargs) ⇒ Object
Wrapping atomic_promote in callbacks gets background promotion, since the shrine pattern for background job for promotion uses atomic_promote.
Instance Method Details
#activerecord_after_save ⇒ Object
For INLINE promotion, we need to wrap this one in callbacks, in order to be wrapping enough to a) be able to cancel in ‘before`, and b) have `after` actually be running after promotion is complete and persisted.
But we only want to do it here for ‘inline’ promotion mode. For ‘false’ disabled promotion, we don’t want to run callbacks at all; and for ‘background’ this is too early, we want callbacks to run in bg job, not here. AND only if we’re actually promoting, otherwise we don’t want to run callbacks!
105 106 107 108 109 110 111 112 113 |
# File 'lib/shrine/plugins/kithe_promotion_callbacks.rb', line 105 def activerecord_after_save if self.promotion_directives["promote"] == "inline" && promote? Shrine::Plugins::KithePromotionCallbacks.with_promotion_callbacks(record) do super end else super end end |
#atomic_promote(*args, **kwargs) ⇒ Object
Wrapping atomic_promote in callbacks gets background promotion, since the shrine pattern for background job for promotion uses atomic_promote. It also gets any ‘manual’ use of atomic promote, such as from our Asset#promote method.
118 119 120 121 122 |
# File 'lib/shrine/plugins/kithe_promotion_callbacks.rb', line 118 def atomic_promote(*args, **kwargs) Shrine::Plugins::KithePromotionCallbacks.with_promotion_callbacks(record) do super end end |