lib/backgrounder/workers/process_asset.rb in carrierwave_backgrounder-0.0.7 vs lib/backgrounder/workers/process_asset.rb in carrierwave_backgrounder-0.0.8
- old
+ new
@@ -1,25 +1,32 @@
# encoding: utf-8
module CarrierWave
module Workers
class ProcessAsset < Struct.new(:klass, :id, :column)
+ include ::Sidekiq::Worker if defined?(::Sidekiq)
@queue = :process_asset
def self.perform(*args)
new(*args).perform
end
- def perform
+ def perform(*args)
+ set_args(*args) unless args.empty?
resource = klass.is_a?(String) ? klass.constantize : klass
record = resource.find id
if record
record.send(:"process_#{column}_upload=", true)
if record.send(:"#{column}").recreate_versions! && record.respond_to?(:"#{column}_processing")
- record.update_attribute :"#{column}_processing", nil
+ record.send :"#{column}_processing=", nil
+ record.save!
end
end
+ end
+
+ def set_args(klass, id, column)
+ self.klass, self.id, self.column = klass, id, column
end
end # ProcessAsset
end # Workers