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.
91 92 93 94 95 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 91 def initialize(record, method_name, *args) @record = record @method_name = method_name @args = args end |
Instance Method Details
#before(job) ⇒ Object
101 102 103 104 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 101 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
97 98 99 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 97 def enqueue(job) update_cached_status(:queued) end |
#error(job, exception) ⇒ Object
116 117 118 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 116 def error(job, exception) update_cached_status(:failure) end |
#failure(job) ⇒ Object
120 121 122 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 120 def failure(job) update_cached_status(:failure) end |
#perform ⇒ Object
106 107 108 109 110 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 106 def perform update_cached_status(:processing) = @args. @record.send(@method_name, *@args, **) end |
#success(job) ⇒ Object
112 113 114 |
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 112 def success(job) update_cached_status(:success) end |