Class: Kithe::AssetPromoteJob
- Defined in:
- app/jobs/kithe/asset_promote_job.rb
Instance Method Summary collapse
-
#perform(attacher_class, record_class, record_id, name, file_data, promotion_directives) ⇒ Object
note we add a ‘promotion_directives` arg on the end, differing from standard shrine.
Instance Method Details
#perform(attacher_class, record_class, record_id, name, file_data, promotion_directives) ⇒ Object
note we add a ‘promotion_directives` arg on the end, differing from standard shrine. It is a hash.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/jobs/kithe/asset_promote_job.rb', line 5 def perform(attacher_class, record_class, record_id, name, file_data, promotion_directives) attacher_class = Object.const_get(attacher_class) record = Object.const_get(record_class).find(record_id) # if using Active Record attacher = attacher_class.retrieve(model: record, name: name, file: file_data) attacher.set_promotion_directives(promotion_directives) attacher.atomic_promote rescue Shrine::AttachmentChanged, ActiveRecord::RecordNotFound # attachment has changed or record has been deleted, nothing to do end |