Module: DelayedPaperclip::ClassMethods

Defined in:
lib/delayed_paperclip.rb

Instance Method Summary collapse

Instance Method Details

#paperclip_definitionsObject



73
74
75
76
77
78
79
# File 'lib/delayed_paperclip.rb', line 73

def paperclip_definitions
  @paperclip_definitions ||= if respond_to? :attachment_definitions
    attachment_definitions
  else
    Paperclip::Tasks::Attachments.definitions_for(self)
  end
end

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/delayed_paperclip.rb', line 49

def process_in_background(name, options = {})
  # initialize as hash
  paperclip_definitions[name][:delayed] = {}

  # Set Defaults
  {
    :priority => 0,
    :only_process => paperclip_definitions[name][:only_process],
    :url_with_processing => DelayedPaperclip.options[:url_with_processing],
    :processing_image_url => options[:processing_image_url]
  }.each do |option, default|

    paperclip_definitions[name][:delayed][option] = options.key?(option) ? options[option] : default

  end

  # Sets callback
  if respond_to?(:after_commit)
    after_commit  :enqueue_delayed_processing
  else
    after_save    :enqueue_delayed_processing
  end
end