module Paperclip::ProcessorHelpers
Public Instance Methods
clear_processors!()
click to toggle source
# File lib/paperclip/processor_helpers.rb, line 33 def clear_processors! @known_processors.try(:clear) end
load_processor(name)
click to toggle source
# File lib/paperclip/processor_helpers.rb, line 17 def load_processor(name) if defined?(Rails.root) && Rails.root filename = "#{name.to_s.underscore}.rb" directories = %w(lib/paperclip lib/paperclip_processors) required = directories.map do |directory| pathname = File.expand_path(Rails.root.join(directory, filename)) file_exists = File.exist?(pathname) require pathname if file_exists file_exists end raise LoadError, "Could not find the '#{name}' processor in any of these paths: #{directories.join(', ')}" unless required.any? end end
register_processor(name, processor)
click to toggle source
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
# File lib/paperclip/processor_helpers.rb, line 45 def register_processor(name, processor) @known_processors ||= {} @known_processors[name.to_s] = processor end