require 'threadify'
module Paperclip
class Attachment
def post_process_styles
@styles.each do |name, args|
raise RuntimeError.new("Style #{name} has no processors defined.") if args[:processors].blank?
end
begin
results =
@styles.threadify(number_of_cpus = 2) do |name, args|
file = @queued_for_write[:original]
args[:processors].map do |processor|
file = Paperclip.processor(processor).make(file, args, self)
end
{name => file}
end
results.each{|result| @queued_for_write.update(result)}
rescue PaperclipError => e
log("An error was received while processing: #{e.inspect}")
(@errors[:processing] ||= []) << e.message if @whiny
end
end
end
end