Class: Tupelo::Client::AtDo

Inherits:
AtDo
  • Object
show all
Defined in:
lib/tupelo/client/atdo.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, **opts) ⇒ AtDo

Returns a new instance of AtDo.



7
8
9
10
# File 'lib/tupelo/client/atdo.rb', line 7

def initialize client, **opts
  @client = client
  super **opts
end

Instance Method Details

#at(time, &action) ⇒ Object

Accepts numeric time. Logs errors in action. Otherwise, same as ::AtDo.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tupelo/client/atdo.rb', line 14

def at time, &action
  time = Time.at(time) if time.kind_of? Numeric
  super time do
    begin
      action.call
    rescue => ex
      @client.log.error "error in action scheduled for #{time}:" +
        " #{ex.class}: #{ex}\n  #{ex.backtrace.join("\n  ")}"
    end
  end
end