Module: Paperclip::ProcessorHelpers

Included in:
Paperclip
Defined in:
lib/paperclip/processor.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) clear_processors!



68
69
70
# File 'lib/paperclip/processor.rb', line 68

def clear_processors!
  @known_processors.try(:clear)
end

- (Object) load_processor(name)



62
63
64
65
66
# File 'lib/paperclip/processor.rb', line 62

def load_processor(name)
  if defined?(Rails.root) && Rails.root
    require File.expand_path(Rails.root.join("lib", "paperclip_processors", "#{name.underscore}.rb"))
  end
end

- (Object) processor(name)

:nodoc:



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/paperclip/processor.rb', line 50

def processor(name) #:nodoc:
  @known_processors ||= {}
  if @known_processors[name.to_s]
    @known_processors[name.to_s]
  else
    name = name.to_s.camelize
    load_processor(name) unless Paperclip.const_defined?(name)
    processor = Paperclip.const_get(name)
    @known_processors[name.to_s] = processor
  end
end

- (Object) register_processor(name, processor)

You can add your own processor via the Paperclip configuration. Normally Paperclip will load all processors from the Rails.root/lib/paperclip_processors directory, but here you can add any existing class using this mechanism.

Paperclip.configure do |c|
  c.register_processor :watermarker, WatermarkingProcessor.new
end


80
81
82
83
# File 'lib/paperclip/processor.rb', line 80

def register_processor(name, processor)
  @known_processors ||= {}
  @known_processors[name.to_s] = processor
end