Module: CarrierWave::Uploader::Processing::ClassMethods
- Defined in:
- lib/carrierwave/uploader/processing.rb
Instance Method Summary collapse
-
#process(*args) ⇒ Object
Adds a processor callback which applies operations as a file is uploaded.
-
#processors ⇒ Object
Lists processor callbacks declared.
Instance Method Details
#process(*args) ⇒ Object
Adds a processor callback which applies operations as a file is uploaded. The argument may be the name of any method of the uploader, expressed as a symbol, or a list of such methods, or a hash where the key is a method and the value is an array of arguments to call the method with
Parameters
args (*Symbol, Hash=> Array[])
Examples
class MyUploader < CarrierWave::Uploader::Base
process :sepiatone, :vignette
process :scale => [200, 200]
def sepiatone
...
end
def vignette
...
end
def scale(height, width)
...
end
end
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/carrierwave/uploader/processing.rb', line 57 def process(*args) args.each do |arg| if arg.is_a?(Hash) arg.each do |method, args| processors.push([method, args]) end else processors.push([arg, []]) end end end |
#processors ⇒ Object
Lists processor callbacks declared
Returns
- Array[Array[Symbol, Array]]
-
a list of processor callbacks which have been declared for this uploader
23 24 25 |
# File 'lib/carrierwave/uploader/processing.rb', line 23 def processors @processors ||= [] end |