defversion(name,options={},&block)name=name.to_symunlessversions[name]uploader=Class.new(self)uploader.versions={}# Define the enable_processing method for versions so they get the# value from the parent class unless explicitly overwrittenuploader.class_eval<<-RUBY,__FILE__,__LINE__+1
def self.enable_processing(value=nil)
self.enable_processing = value if value
if !@enable_processing.nil?
@enable_processing
else
superclass.enable_processing
end
end
RUBY# Add the current version hash to class attribute :versionscurrent_version={}current_version[name]={:uploader=>uploader,:options=>options}self.versions=versions.merge(current_version)versions[name][:uploader].version_names+=[name]class_eval<<-RUBY
def #{name}
versions[:#{name}]
end
RUBY# as the processors get the output from the previous processors as their# input we must not stack the processors hereversions[name][:uploader].processors=versions[name][:uploader].processors.dupversions[name][:uploader].processors.clearendversions[name][:uploader].class_eval(&block)ifblockversions[name]end