module Shrine::Plugins::KithePromotionCallbacks::AttacherMethods

Public Instance Methods

activerecord_after_save() click to toggle source

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!

Calls superclass method
# File lib/shrine/plugins/kithe_promotion_callbacks.rb, line 64
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) click to toggle source

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.

Calls superclass method
# File lib/shrine/plugins/kithe_promotion_callbacks.rb, line 77
def atomic_promote(*args, **kwargs)
  Shrine::Plugins::KithePromotionCallbacks.with_promotion_callbacks(record) do
    super
  end
end