Class: Dynflow::Testing::ManagedClock

Inherits:
Object
  • Object
show all
Includes:
Algebrick::Types
Defined in:
lib/dynflow/testing/managed_clock.rb

Defined Under Namespace

Modules: Timer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManagedClock

Returns a new instance of ManagedClock.



19
20
21
# File 'lib/dynflow/testing/managed_clock.rb', line 19

def initialize
  @pending_pings = []
end

Instance Attribute Details

#pending_pingsObject (readonly)

Returns the value of attribute pending_pings.



5
6
7
# File 'lib/dynflow/testing/managed_clock.rb', line 5

def pending_pings
  @pending_pings
end

Instance Method Details

#clearObject



34
35
36
# File 'lib/dynflow/testing/managed_clock.rb', line 34

def clear
  @pending_pings.clear
end

#ping(who, time, with_what = nil, where = :<<) ⇒ Object



23
24
25
26
# File 'lib/dynflow/testing/managed_clock.rb', line 23

def ping(who, time, with_what = nil, where = :<<)
  with = with_what.nil? ? None : Some[Object][with_what]
  @pending_pings << Timer[who, time, with, where]
end

#progressObject



28
29
30
31
32
# File 'lib/dynflow/testing/managed_clock.rb', line 28

def progress
  copy = @pending_pings.dup
  clear
  copy.each { |ping| ping.apply }
end