Class: SpatialFeatures::QueuedSpatialProcessing::SpatialProcessingJob

Inherits:
Object
  • Object
show all
Defined in:
lib/spatial_features/has_spatial_features/queued_spatial_processing.rb

Overview

CLASSES

Instance Method Summary collapse

Constructor Details

#initialize(record, method_name, *args) ⇒ SpatialProcessingJob

Returns a new instance of SpatialProcessingJob.



103
104
105
106
107
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 103

def initialize(record, method_name, *args)
  @record = record
  @method_name = method_name
  @args = args
end

Instance Method Details

#before(job) ⇒ Object



113
114
115
116
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 113

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



109
110
111
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 109

def enqueue(job)
  update_cached_status(:queued)
end

#error(job, exception) ⇒ Object



128
129
130
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 128

def error(job, exception)
  update_cached_status(:failure)
end

#failure(job) ⇒ Object



132
133
134
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 132

def failure(job)
  update_cached_status(:failure)
end

#performObject



118
119
120
121
122
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 118

def perform
  update_cached_status(:processing)
  options = @args.extract_options!
  @record.send(@method_name, *@args, **options)
end

#success(job) ⇒ Object



124
125
126
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 124

def success(job)
  update_cached_status(:success)
end