Skip to content

Commit

Permalink
Adding possibility to disable the url overwriting of attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertg committed Aug 31, 2011
1 parent 322d460 commit 508a5b9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/delayed_paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class << self

def options
@options ||= {
:background_job_class => detect_background_task
:background_job_class => detect_background_task,
:url_with_processing => true
}
end

Expand Down Expand Up @@ -45,7 +46,12 @@ def process_in_background(name, options = {})
include InstanceMethods

attachment_definitions[name][:delayed] = {}
attachment_definitions[name][:delayed][:priority] = options.key?(:priority) ? options[:priority] : 0
{
: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
Expand Down Expand Up @@ -117,7 +123,7 @@ def save_with_prepare_enqueueing
alias_method_chain :save, :prepare_enqueueing

def url_with_processed style = default_style, include_updated_timestamp = @use_timestamp
return url_without_processed style, include_updated_timestamp if job_is_processing
return url_without_processed style, include_updated_timestamp if !@instance.class.attachment_definitions[@name][:delayed].try(:[], :url_with_processing) || job_is_processing

if !@instance.respond_to?(:"#{name}_processing?")
url_without_processed style, include_updated_timestamp
Expand Down

0 comments on commit 508a5b9

Please sign in to comment.