Module: DelayedPaperclip::UrlGenerator

Defined in:
lib/delayed_paperclip/url_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
# File 'lib/delayed_paperclip/url_generator.rb', line 5

def self.included(base)
  base.alias_method_chain :most_appropriate_url, :processed
  base.alias_method_chain :timestamp_possible?, :processed
end

Instance Method Details

#delayed_default_url?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/delayed_paperclip/url_generator.rb', line 30

def delayed_default_url?
  return false if @attachment.job_is_processing
  return false if @attachment.dirty?
  return false if not @attachment.delayed_options.try(:[], :url_with_processing)
  return false if not (@attachment.instance.respond_to?(:"#{@attachment.name}_processing?") && @attachment.processing?)
  true

  # OLD CRAZY CONDITIONAL
  # TODO: Delete
  # !(
  #   @attachment.job_is_processing ||
  #   @attachment.dirty? ||
  #   [email protected]_options.try(:[], :url_with_processing) ||
  #   !(@attachment.instance.respond_to?(:"#{@attachment.name}_processing?") && @attachment.processing?)
  # )
end

#most_appropriate_url_with_processedObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/delayed_paperclip/url_generator.rb', line 10

def most_appropriate_url_with_processed
  if @attachment.original_filename.nil? || delayed_default_url?
    if @attachment.delayed_options.nil? || @attachment.processing_image_url.nil? || !@attachment.processing?
      default_url
    else
      @attachment.processing_image_url
    end
  else
    @attachment_options[:url]
  end
end

#timestamp_possible_with_processed?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/delayed_paperclip/url_generator.rb', line 22

def timestamp_possible_with_processed?
  if delayed_default_url?
    false
  else
    timestamp_possible_without_processed?
  end
end