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

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) recursively_apply_block_to_versions(&block)



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.class_eval(&block)
    version.recursively_apply_block_to_versions(&block)
  end
end

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

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].class_eval(&block) if block
  versions[name]
end