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.
129 130 131 132 133 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 129 def initialize(record, method_name, *args) @record = record @method_name = method_name @args = args end |
Instance Method Details
#before(job) ⇒ Object
139 140 141 142 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 139 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
135 136 137 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 135 def enqueue(job) update_cached_status(:queued) end |
#error(job, exception) ⇒ Object
154 155 156 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 154 def error(job, exception) update_cached_status(:failure) end |
#failure(job) ⇒ Object
158 159 160 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 158 def failure(job) update_cached_status(:failure) end |
#perform ⇒ Object
144 145 146 147 148 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 144 def perform update_cached_status(:processing) = @args. @record.send(@method_name, *@args, **) end |
#success(job) ⇒ Object
150 151 152 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 150 def success(job) update_cached_status(:success) end |