Module: DelayedPaperclip::Attachment
- Defined in:
- lib/delayed_paperclip/attachment.rb
Instance Attribute Summary collapse
-
#job_is_processing ⇒ Object
Returns the value of attribute job_is_processing.
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 ⇒ Object
Attr accessor in Paperclip.
- #post_processing=(value) ⇒ Object
- #process_delayed! ⇒ Object
- #processing? ⇒ Boolean
- #processing_image_url ⇒ Object
- #processing_style?(style) ⇒ Boolean
- #reprocess_without_delay!(*style_args) ⇒ Object
- #save ⇒ Object
- #split_processing? ⇒ Boolean
Instance Attribute Details
#job_is_processing ⇒ Object
Returns the value of attribute job_is_processing.
3 4 5 |
# File 'lib/delayed_paperclip/attachment.rb', line 3 def job_is_processing @job_is_processing end |
Instance Method Details
#delay_processing? ⇒ Boolean
if nil, returns whether it has delayed options if set, then it returns
20 21 22 23 24 25 26 |
# File 'lib/delayed_paperclip/attachment.rb', line 20 def delay_processing? if @post_processing_with_delay.nil? !! else !@post_processing_with_delay end end |
#delayed_only_process ⇒ Object
44 45 46 47 48 |
# File 'lib/delayed_paperclip/attachment.rb', line 44 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
5 6 7 |
# File 'lib/delayed_paperclip/attachment.rb', line 5 def [:delayed] end |
#post_processing ⇒ Object
Attr accessor in Paperclip
10 11 12 |
# File 'lib/delayed_paperclip/attachment.rb', line 10 def post_processing !delay_processing? || split_processing? end |
#post_processing=(value) ⇒ Object
14 15 16 |
# File 'lib/delayed_paperclip/attachment.rb', line 14 def post_processing=(value) @post_processing_with_delay = value end |
#process_delayed! ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/delayed_paperclip/attachment.rb', line 50 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
33 34 35 36 |
# File 'lib/delayed_paperclip/attachment.rb', line 33 def processing? column_name = :"#{@name}_processing?" @instance.respond_to?(column_name) && @instance.send(column_name) end |
#processing_image_url ⇒ Object
58 59 60 61 62 |
# File 'lib/delayed_paperclip/attachment.rb', line 58 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
38 39 40 41 42 |
# File 'lib/delayed_paperclip/attachment.rb', line 38 def processing_style?(style) return false if !processing? !split_processing? || delayed_only_process.include?(style) end |
#reprocess_without_delay!(*style_args) ⇒ Object
74 75 76 77 |
# File 'lib/delayed_paperclip/attachment.rb', line 74 def reprocess_without_delay!(*style_args) @post_processing_with_delay = true reprocess!(*style_args) end |
#save ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/delayed_paperclip/attachment.rb', line 64 def save was_dirty = @dirty super.tap do if delay_processing? && was_dirty instance.prepare_enqueueing_for name end end end |
#split_processing? ⇒ Boolean
28 29 30 31 |
# File 'lib/delayed_paperclip/attachment.rb', line 28 def split_processing? [:only_process] && && [:only_process] != delayed_only_process end |