Module: DelayedPaperclip::Attachment::InstanceMethods

Defined in:
lib/delayed_paperclip/attachment.rb

Instance Method Summary collapse

Instance Method Details

#delay_processing?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/delayed_paperclip/attachment.rb', line 24

def delay_processing?
  if @post_processing_with_delay.nil?
    !!@instance.class.attachment_definitions[@name][:delayed]
  else
     !@post_processing_with_delay
  end
end

#post_process_styles_with_processing(*args) ⇒ Object



42
43
44
45
# File 'lib/delayed_paperclip/attachment.rb', line 42

def post_process_styles_with_processing(*args)
  post_process_styles_without_processing(*args)
  instance.update_attribute("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?")
end

#post_processing_with_delayObject



16
17
18
# File 'lib/delayed_paperclip/attachment.rb', line 16

def post_processing_with_delay
  !delay_processing?
end

#post_processing_with_delay=(value) ⇒ Object



20
21
22
# File 'lib/delayed_paperclip/attachment.rb', line 20

def post_processing_with_delay=(value)
  @post_processing_with_delay = value
end

#process_delayed!Object



36
37
38
39
40
# File 'lib/delayed_paperclip/attachment.rb', line 36

def process_delayed!
  self.job_is_processing = true
  reprocess!
  self.job_is_processing = false
end

#processing?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/delayed_paperclip/attachment.rb', line 32

def processing?
  @instance.send(:"#{@name}_processing?")
end

#save_with_prepare_enqueueingObject



47
48
49
50
51
52
53
54
# File 'lib/delayed_paperclip/attachment.rb', line 47

def save_with_prepare_enqueueing
  was_dirty = @dirty
  save_without_prepare_enqueueing.tap do
    if delay_processing? && was_dirty
      instance.prepare_enqueueing_for name
    end
  end
end

#url_with_processed(style = default_style, include_updated_timestamp = @use_timestamp) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/delayed_paperclip/attachment.rb', line 56

def url_with_processed style = default_style, include_updated_timestamp = @use_timestamp
  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
  else
    if !processing?
      url_without_processed style, include_updated_timestamp
    else
      if dirty?
        url_without_processed style, include_updated_timestamp
      else
        interpolate(@default_url, style)
      end
    end
  end
end