Module: DelayedPaperclip::Attachment::InstanceMethods
- Defined in:
- lib/delayed_paperclip/attachment.rb
Instance Method Summary collapse
-
#after_flush_writes_with_processing(*args) ⇒ Object
Updates _processing column to false.
-
#delay_processing? ⇒ Boolean
if nil, returns whether it has delayed options if set, then it returns.
- #delayed_options ⇒ Object
-
#post_processing_with_delay ⇒ Object
Attr accessor in Paperclip.
- #post_processing_with_delay=(value) ⇒ Object
- #process_delayed! ⇒ Object
- #processing? ⇒ Boolean
- #processing_image_url ⇒ Object
- #reprocess_without_delay!(*style_args) ⇒ Object
- #save_with_prepare_enqueueing ⇒ Object
Instance Method Details
#after_flush_writes_with_processing(*args) ⇒ Object
Updates _processing column to false
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/delayed_paperclip/attachment.rb', line 56 def after_flush_writes_with_processing(*args) after_flush_writes_without_processing(*args) # update_column is available in rails 3.1 instead we can do this to update the attribute without callbacks # instance.update_column("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?") if instance.respond_to?(:"#{name}_processing?") instance.send("#{name}_processing=", false) instance.class.where(instance.class.primary_key => instance.id).update_all({ "#{name}_processing" => false }) end end |
#delay_processing? ⇒ Boolean
if nil, returns whether it has delayed options if set, then it returns
30 31 32 33 34 35 36 |
# File 'lib/delayed_paperclip/attachment.rb', line 30 def delay_processing? if @post_processing_with_delay.nil? !! else !@post_processing_with_delay end end |
#delayed_options ⇒ Object
15 16 17 |
# File 'lib/delayed_paperclip/attachment.rb', line 15 def @instance.class.paperclip_definitions[@name][:delayed] end |
#post_processing_with_delay ⇒ Object
Attr accessor in Paperclip
20 21 22 |
# File 'lib/delayed_paperclip/attachment.rb', line 20 def post_processing_with_delay !delay_processing? end |
#post_processing_with_delay=(value) ⇒ Object
24 25 26 |
# File 'lib/delayed_paperclip/attachment.rb', line 24 def post_processing_with_delay=(value) @post_processing_with_delay = value end |
#process_delayed! ⇒ Object
42 43 44 45 46 47 |
# File 'lib/delayed_paperclip/attachment.rb', line 42 def process_delayed! self.job_is_processing = true self.post_processing = true reprocess!(*[:only_process]) self.job_is_processing = false end |
#processing? ⇒ Boolean
38 39 40 |
# File 'lib/delayed_paperclip/attachment.rb', line 38 def processing? @instance.send(:"#{@name}_processing?") end |
#processing_image_url ⇒ Object
49 50 51 52 53 |
# File 'lib/delayed_paperclip/attachment.rb', line 49 def processing_image_url processing_image_url = [:delayed][:processing_image_url] processing_image_url = processing_image_url.call(self) if processing_image_url.respond_to?(:call) processing_image_url end |
#reprocess_without_delay!(*style_args) ⇒ Object
77 78 79 80 |
# File 'lib/delayed_paperclip/attachment.rb', line 77 def reprocess_without_delay!(*style_args) @post_processing_with_delay = true reprocess!(*style_args) end |
#save_with_prepare_enqueueing ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/delayed_paperclip/attachment.rb', line 67 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 |