Module: DelayedPaperclip::ClassMethods

Defined in:
lib/delayed_paperclip.rb

Instance Method Summary collapse

Instance Method Details

#process_in_background(name, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/delayed_paperclip.rb', line 42

def process_in_background(name, options = {})
  include InstanceMethods

  attachment_definitions[name][:delayed] = {}
  {
    :priority => 0,
    :url_with_processing => DelayedPaperclip.options[:url_with_processing]
  }.each do |option, default|
    attachment_definitions[name][:delayed][option] = options.key?(option) ? options[option] : default
  end

  if respond_to?(:after_commit)
    after_commit  :enqueue_delayed_processing
  else
    after_save  :enqueue_delayed_processing
  end
end