class Shrine::Plugins::KithePromotionDirectives

This adds some features around shrine promotion that we found useful for dealing with backgrounding promotion.

By default the kithe setup:

There are times you want to customize these life cycle actions, either disabling them, or switching them from a background job to happen inline in the foreground. Some use cases for this are: 1) in automated testing; 2) when you are running a batch job (eg batch import), you might want to disable some expensive things per-record to instead do them all in batch at the end, or run them inline to keep from clogging up your bg job queue, and have better 'backpressure'.

We provide something we call “promotion directives” to let you customize these. You can set them on a shrine Attacher; or on a Kithe `Asset` model individually, or globally on the class.

## Directives

# Examples of setting

## Globally on Kithe::Asset

Useful for batch processing or changing test defaults.

Kithe::Asset.promotion_directives = { promote: :inline, create_derivatives: false }

## On a Kithe::Asset individual model

asset = Kithe:Assst.new
asset.set_promotion_directives(create_derivatives: :inline)

(Aggregates on top of whatever was set at class level of previously set with `Asset#set_promotion_directives)`, does not replace previously settings but merges into them!

## Directly on a shrine attacher

some_asset.file = some_assignable_file
some_asset.file_attacher.set_promotion_directives(skip_callbacks: true)
some_asset.save!

(Aggregates on top of whatever was already set, merges into it, does not replace!)

## Checking current settings

some_asset.promotion_directives

or

some_asset.file_attacher.promotion_directives