class Tisket::Task::Polling

Public Class Methods

attr_names() click to toggle source
Calls superclass method Task::attr_names
# File lib/tisket/polling.rb, line 3
def self.attr_names
  super + %i[ max_retries poll_interval ]
end
defaults() click to toggle source
Calls superclass method Task::defaults
# File lib/tisket/polling.rb, line 7
def self.defaults
  super.merge(
    max_retries: 10,
    poll_interval: 30 ) # seconds
end

Public Instance Methods

done?() click to toggle source
# File lib/tisket/polling.rb, line 13
def done?
  raise 'Abstract method'
end
poll() click to toggle source
# File lib/tisket/polling.rb, line 17
def poll
  @max_retries.times do
    done? ? break : sleep(@poll_interval)
  end
end
run() click to toggle source
Calls superclass method Task#run
# File lib/tisket/polling.rb, line 23
def run
  super do
    start
    poll
  end
end
start() click to toggle source
# File lib/tisket/polling.rb, line 30
def start
  raise 'Abstract method'
end