Module: CarrierWave::Uploader::Versions::ClassMethods

Defined in:
lib/carrierwave/uploader/versions.rb

Instance Method Summary collapse

Instance Method Details

#recursively_apply_block_to_versions(&block) ⇒ Object



59
60
61
62
63
64
# File 'lib/carrierwave/uploader/versions.rb', line 59

def recursively_apply_block_to_versions(&block)
  versions.each do |name, version|
    version[:uploader].class_eval(&block)
    version[:uploader].recursively_apply_block_to_versions(&block)
  end
end

#version(name, options = {}, &block) ⇒ Object

Adds a new version to this uploader

Parameters

name (#to_sym)

name of the version

options (Hash)

optional options hash

&block (Proc)

a block to eval on this version of the uploader

Examples

class MyUploader < CarrierWave::Uploader::Base

  version :thumb do
    process :scale => [200, 200]
  end

  version :preview, :if => :image? do
    process :scale => [200, 200]
  end

end


51
52
53
54
55
56
57
# File 'lib/carrierwave/uploader/versions.rb', line 51

def version(name, options = {}, &block)
  name = name.to_sym
  build_version(name, options) unless versions[name]

  versions[name][:uploader].class_eval(&block) if block
  versions[name]
end