Class: Respawn::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/respawn/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(onfail) ⇒ Handler

Returns a new instance of Handler.



3
4
5
6
7
# File 'lib/respawn/handler.rb', line 3

def initialize(onfail)
  self.onfail = onfail
  self.retry_number = 0
  # self.predicates = []
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



25
26
27
# File 'lib/respawn/handler.rb', line 25

def block
  @block
end

#retry_numberObject

Returns the value of attribute retry_number.



23
24
25
# File 'lib/respawn/handler.rb', line 23

def retry_number
  @retry_number
end

Instance Method Details

#define(&block) ⇒ Object

def predicate(&block)

self.predicates << block

end



13
14
15
16
17
18
19
20
21
# File 'lib/respawn/handler.rb', line 13

def define(&block)
  return if self.block

  if onfail != :handler
    raise Error, "Cannot define a block unless onfail is :handler"
  end

  self.block = block
end