Module: Paperclip::ProcessorHelpers
- Included in:
- Paperclip
- Defined in:
- lib/paperclip/processor.rb
Instance Method Summary collapse
- #clear_processors! ⇒ Object
- #load_processor(name) ⇒ Object
-
#processor(name) ⇒ Object
:nodoc:.
-
#register_processor(name, processor) ⇒ Object
You can add your own processor via the Paperclip configuration.
Instance Method Details
#clear_processors! ⇒ Object
56 57 58 |
# File 'lib/paperclip/processor.rb', line 56 def clear_processors! @known_processors.try(:clear) end |
#load_processor(name) ⇒ Object
50 51 52 53 54 |
# File 'lib/paperclip/processor.rb', line 50 def load_processor(name) if defined?(Rails.root) && Rails.root require File.(Rails.root.join("lib", "paperclip_processors", "#{name.underscore}.rb")) end end |
#processor(name) ⇒ Object
:nodoc:
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/paperclip/processor.rb', line 38 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 |
#register_processor(name, processor) ⇒ Object
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
68 69 70 71 |
# File 'lib/paperclip/processor.rb', line 68 def register_processor(name, processor) @known_processors ||= {} @known_processors[name.to_s] = processor end |