29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/carrierwave/processor/configuration.rb', line 29
def backend name=nil, options={}
if name
backends_path = (::CarrierWave::Processor.root + 'carrierwave/processor/backend')
backend_file = backends_path.entries.detect{|i| i.basename('.rb').to_s == name.to_s}
raise BackendNotFound.new(name) unless backend_file
backend_file = backends_path + backend_file
require backend_file
raise BackendNotFound.new(name) unless backend_file
begin
klass = ::CarrierWave::Processor::Backend.const_get(name.to_s.classify.to_sym)
rescue NameError
raise BackendNotFound.new(name)
end
options = @backend.options.merge(options) if @backend
@backend = klass.new options
elsif @backend
@backend
else
raise BackendNotInitializedError.new
end
end
|