Module: CarrierWave::Uploader::Processing
- Extended by:
- ActiveSupport::Concern
- Includes:
- Callbacks
- Included in:
- Base
- Defined in:
- lib/carrierwave/uploader/processing.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#process!(new_file = nil) ⇒ Object
Apply all process callbacks added through CarrierWave.process.
Methods included from Callbacks
Instance Method Details
#process!(new_file = nil) ⇒ Object
Apply all process callbacks added through CarrierWave.process
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/carrierwave/uploader/processing.rb', line 81 def process!(new_file=nil) return unless enable_processing with_callbacks(:process, new_file) do self.class.processors.each do |method, args, condition, condition_type| if condition && condition_type == :if if condition.respond_to?(:call) next unless condition.call(self, :args => args, :method => method, :file => new_file) else next unless self.send(condition, new_file) end elsif condition && condition_type == :unless if condition.respond_to?(:call) next if condition.call(self, :args => args, :method => method, :file => new_file) elsif self.send(condition, new_file) next end end if args.is_a? Array kwargs, args = args.partition { |arg| arg.is_a? Hash } end if kwargs.present? kwargs = kwargs.reduce(:merge) self.send(method, *args, **kwargs) else self.send(method, *args) end end end end |