lib/carrierwave/processor/uploader_dsl.rb in carrierwave-processor-1.0.3 vs lib/carrierwave/processor/uploader_dsl.rb in carrierwave-processor-1.1.0
- old
+ new
@@ -2,24 +2,39 @@
module CarrierWave
module Processor
module UploaderDsl
- def use_processor *args
- options = args.extract_options!
- args.each do |processor|
- if processor and not ::CarrierWave::Processor.processors.blank? and real_processor = ::CarrierWave::Processor.processors[processor] and real_processor[:block]
- new_if = [options[:if], real_processor[:options][:if]]
- merged_options = real_processor[:options].merge options
- merged_options[:if] = new_if if new_if
- Injector.new(self, merged_options, &real_processor[:block])
- else
- raise ProcessorNotFoundError, processor
+ def self.included base
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+
+ def use_processor *args
+ options = args.extract_options!
+ args.each do |processor|
+ if processor and not ::CarrierWave::Processor.processors.blank? and real_processor = ::CarrierWave::Processor.processors[processor] and real_processor[:block]
+ new_if = [options[:if], real_processor[:options][:if]]
+ merged_options = real_processor[:options].merge options
+ merged_options[:if] = new_if if new_if
+ Injector.new(self, merged_options, &real_processor[:block])
+ else
+ raise ProcessorNotFoundError, processor
+ end
end
end
+
+ alias_method :use_processors, :use_processor
+
end
- alias_method :use_processors, :use_processor
+ def perform_delayed *args
+ backend = ::CarrierWave::Processor.configuration.backend
+ if !backend.can_build_uploader?(self.class) and backend.uploaders.include? self.class
+ ::CarrierWave::Processor.configuration.backend.create_worker.perform(self)
+ end
+ end
end
end
end
\ No newline at end of file