Class: Gemgento::ApiJob

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gemgento/api_job.rb

Overview

Author:

  • Gemgento LLC

Instance Method Summary collapse

Instance Method Details

#activate(payload) ⇒ void

This method returns an undefined value.

Perform the ApiJob. This is meant to be overridden in the child class. The requirements of overriding this method are to transition the ApiJob into the active state before doing anything, then upon completion, transition to either the complete or error state.



61
62
63
64
65
# File 'app/models/gemgento/api_job.rb', line 61

def activate(payload)
  self.active
  # perform action here
  self.complete
end

#error!void

This method returns an undefined value.

Print the ApiJob details after the ApiJob has transitioned to the error state.



45
46
47
# File 'app/models/gemgento/api_job.rb', line 45

def error!
  puts(self.inspect)
end

#finalize!void

This method returns an undefined value.

Lock the ApiJob after it has transitioned to the complete state.



52
53
54
# File 'app/models/gemgento/api_job.rb', line 52

def finalize!
  self.update_attribute('locked', true)
end

#is_completed!void

This method returns an undefined value.

Determine if the ApiJob is completed. This method needs to be overridden in the child class.



39
40
# File 'app/models/gemgento/api_job.rb', line 39

def is_completed!
end

#is_ready!void

This method returns an undefined value.

Determine if the ApiJob is ready to be activated. This method needs to be overridden in the child class.



33
34
# File 'app/models/gemgento/api_job.rb', line 33

def is_ready!
end