Module: CarrierWave::Uploader::Versions::ClassMethods
- Defined in:
- lib/carrierwave/uploader/versions.rb
Instance Method Summary collapse
-
#version(name, options = {}, &block) ⇒ Object
Adds a new version to this uploader.
Instance Method Details
#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
version :square, :unless => :invalid_image_type? do
process :scale => [100, 100]
end
end
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/carrierwave/uploader/versions.rb', line 142 def version(name, = {}, &block) name = name.to_sym versions[name] ||= Builder.new(name) versions[name].configure(, &block) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} versions[:#{name}] end RUBY versions[name] end |