Class: RestCore::Timeout::TimerEm

Inherits:
EventMachine::Timer
  • Object
show all
Defined in:
lib/rest-core/middleware/timeout/timer_em.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TimerEm) initialize(timeout, error, &block)

Returns a new instance of TimerEm



7
8
9
10
11
12
# File 'lib/rest-core/middleware/timeout/timer_em.rb', line 7

def initialize timeout, error, &block
  super(timeout, &block) if block_given?
  self.timeout = timeout
  self.error   = error
  @canceled    = false
end

Instance Attribute Details

- (Object) error

Returns the value of attribute error



5
6
7
# File 'lib/rest-core/middleware/timeout/timer_em.rb', line 5

def error
  @error
end

- (Object) timeout

Returns the value of attribute timeout



5
6
7
# File 'lib/rest-core/middleware/timeout/timer_em.rb', line 5

def timeout
  @timeout
end

Instance Method Details

- (Object) cancel



18
19
20
21
# File 'lib/rest-core/middleware/timeout/timer_em.rb', line 18

def cancel
  super
  @canceled = true
end

- (Boolean) canceled?

Returns:

  • (Boolean)


23
24
25
# File 'lib/rest-core/middleware/timeout/timer_em.rb', line 23

def canceled?
  @canceled
end

- (Object) on_timeout(&block)



14
15
16
# File 'lib/rest-core/middleware/timeout/timer_em.rb', line 14

def on_timeout &block
  send(:initialize, timeout, error, &block)
end