Module: CarrierWave::Uploader::Versions::ClassMethods
- Defined in:
- lib/carrierwave/uploader/versions.rb
Instance Method Summary collapse
-
#version(name, &block) ⇒ Object
Adds a new version to this uploader.
- #version_names ⇒ Object
-
#versions ⇒ Object
Returns.
Instance Method Details
#version(name, &block) ⇒ Object
Adds a new version to this uploader
Parameters
- name (#to_sym)
-
name of the version
- &block (Proc)
-
a block to eval on this version of the uploader
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/carrierwave/uploader/versions.rb', line 32 def version(name, &block) name = name.to_sym unless versions[name] versions[name] = Class.new(self) versions[name].version_names.push(*version_names) versions[name].version_names.push(name) class_eval <<-RUBY def #{name} versions[:#{name}] end RUBY end versions[name].class_eval(&block) if block versions[name] end |
#version_names ⇒ Object
20 21 22 |
# File 'lib/carrierwave/uploader/versions.rb', line 20 def version_names @version_names ||= [] end |
#versions ⇒ Object
Returns
- Hash=> Class
-
a list of versions available for this uploader
53 54 55 |
# File 'lib/carrierwave/uploader/versions.rb', line 53 def versions @versions ||= {} end |