Class: SpatialFeatures::QueuedSpatialProcessing::SpatialProcessingJob
- Inherits:
-
Object
- Object
- SpatialFeatures::QueuedSpatialProcessing::SpatialProcessingJob
- Defined in:
- lib/spatial_features/has_spatial_features/queued_spatial_processing.rb
Overview
CLASSES
Instance Method Summary collapse
- #before(job) ⇒ Object
- #enqueue(job) ⇒ Object
- #error(job, exception) ⇒ Object
- #failure(job) ⇒ Object
-
#initialize(record, method_name, *args) ⇒ SpatialProcessingJob
constructor
A new instance of SpatialProcessingJob.
- #perform ⇒ Object
- #success(job) ⇒ Object
Constructor Details
#initialize(record, method_name, *args) ⇒ SpatialProcessingJob
Returns a new instance of SpatialProcessingJob.
90 91 92 93 94 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 90 def initialize(record, method_name, *args) @record = record @method_name = method_name @args = args end |
Instance Method Details
#before(job) ⇒ Object
100 101 102 103 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 100 def before(job) ids = running_jobs.where.not(:id => job.id).pluck(:id) raise "Already processing delayed jobs in this spatial queue: Delayed::Job #{ids.to_sentence}." if ids.present? end |
#enqueue(job) ⇒ Object
96 97 98 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 96 def enqueue(job) update_cached_status(:queued) end |
#error(job, exception) ⇒ Object
115 116 117 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 115 def error(job, exception) update_cached_status(:failure) end |
#failure(job) ⇒ Object
119 120 121 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 119 def failure(job) update_cached_status(:failure) end |
#perform ⇒ Object
105 106 107 108 109 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 105 def perform update_cached_status(:processing) = @args. @record.send(@method_name, *@args, **) end |
#success(job) ⇒ Object
111 112 113 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 111 def success(job) update_cached_status(:success) end |