Module: CarrierWave::Uploader::Versions::ClassMethods
- Defined in:
- lib/carrierwave/uploader/versions.rb
Instance Method Summary collapse
- #recursively_apply_block_to_versions(&block) ⇒ Object
-
#version(name, options = {}, &block) ⇒ Object
Adds a new version to this uploader.
Instance Method Details
#recursively_apply_block_to_versions(&block) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/carrierwave/uploader/versions.rb', line 64 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 |
#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
56 57 58 59 60 61 62 |
# File 'lib/carrierwave/uploader/versions.rb', line 56 def version(name, = {}, &block) name = name.to_sym build_version(name, ) versions[name].class_eval(&block) if block versions[name] end |