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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/carrierwave/uploader/versions.rb', line 31 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
19 20 21 |
# File 'lib/carrierwave/uploader/versions.rb', line 19 def version_names @version_names ||= [] end |
#versions ⇒ Object
Returns
- Hash=> Class
-
a list of versions available for this uploader
52 53 54 |
# File 'lib/carrierwave/uploader/versions.rb', line 52 def versions @versions ||= {} end |