Module: DelayedPaperclip::Attachment::InstanceMethods
- Defined in:
- lib/delayed_paperclip/attachment.rb
Instance Method Summary collapse
-
#delay_processing? ⇒ Boolean
if nil, returns whether it has delayed options if set, then it returns.
- #delayed_only_process ⇒ Object
- #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
- #processing_style?(style) ⇒ Boolean
- #reprocess_without_delay!(*style_args) ⇒ Object
- #save_with_prepare_enqueueing ⇒ Object
- #split_processing? ⇒ Boolean
Instance Method Details
#delay_processing? ⇒ Boolean
if nil, returns whether it has delayed options if set, then it returns
35 36 37 38 39 40 41 |
# File 'lib/delayed_paperclip/attachment.rb', line 35 def delay_processing? if @post_processing_with_delay.nil? !! else !@post_processing_with_delay end end |
#delayed_only_process ⇒ Object
59 60 61 62 63 |
# File 'lib/delayed_paperclip/attachment.rb', line 59 def delayed_only_process only_process = .fetch(:only_process, []).dup only_process = only_process.call(self) if only_process.respond_to?(:call) only_process.map(&:to_sym) end |
#delayed_options ⇒ Object
20 21 22 |
# File 'lib/delayed_paperclip/attachment.rb', line 20 def [:delayed] end |
#post_processing_with_delay ⇒ Object
Attr accessor in Paperclip
25 26 27 |
# File 'lib/delayed_paperclip/attachment.rb', line 25 def post_processing_with_delay !delay_processing? || split_processing? end |
#post_processing_with_delay=(value) ⇒ Object
29 30 31 |
# File 'lib/delayed_paperclip/attachment.rb', line 29 def post_processing_with_delay=(value) @post_processing_with_delay = value end |
#process_delayed! ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/delayed_paperclip/attachment.rb', line 65 def process_delayed! self.job_is_processing = true self.post_processing = true reprocess!(*delayed_only_process) self.job_is_processing = false update_processing_column end |
#processing? ⇒ Boolean
48 49 50 51 |
# File 'lib/delayed_paperclip/attachment.rb', line 48 def processing? column_name = :"#{@name}_processing?" @instance.respond_to?(column_name) && @instance.send(column_name) end |
#processing_image_url ⇒ Object
73 74 75 76 77 |
# File 'lib/delayed_paperclip/attachment.rb', line 73 def processing_image_url processing_image_url = [:processing_image_url] processing_image_url = processing_image_url.call(self) if processing_image_url.respond_to?(:call) processing_image_url end |
#processing_style?(style) ⇒ Boolean
53 54 55 56 57 |
# File 'lib/delayed_paperclip/attachment.rb', line 53 def processing_style?(style) return false if !processing? !split_processing? || delayed_only_process.include?(style) end |
#reprocess_without_delay!(*style_args) ⇒ Object
89 90 91 92 |
# File 'lib/delayed_paperclip/attachment.rb', line 89 def reprocess_without_delay!(*style_args) @post_processing_with_delay = true reprocess!(*style_args) end |
#save_with_prepare_enqueueing ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/delayed_paperclip/attachment.rb', line 79 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 |
#split_processing? ⇒ Boolean
43 44 45 46 |
# File 'lib/delayed_paperclip/attachment.rb', line 43 def split_processing? [:only_process] && && [:only_process] != delayed_only_process end |