class OFlow::Test::ActorWrap
Attributes
actor[R]
history[R]
Array of Actions. Log entries appear with a destination of :log.
name[RW]
Public Class Methods
new(name, actor_class, options={})
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 12 def initialize(name, actor_class, options={}) @name = name @before = [] @state = options.fetch(:state, Task::RUNNING) @starting = true @actor = actor_class.new(self, options) @starting = false @history = [] @before.each do |req| receive(req[0], req[1]) end end
Public Instance Methods
debug(msg)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 83 def debug(msg) log_msg(:debug, msg, full_name()) end
error(msg)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 91 def error(msg) log_msg(:error, msg, full_name()) end
fatal(msg)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 99 def fatal(msg) log_msg(:fatal, msg, full_name()) end
full_name()
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 29 def full_name() ":test:#{@name}" end
handle_error(e)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 61 def handle_error(e) #puts "*** #{e.class}: #{e.message}" @history << Action.new(:error, Box.new([e, full_name()])) end
info(msg)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 87 def info(msg) log_msg(:info, msg, full_name()) end
join(timeout)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 66 def join(timeout) giveup = Time.now + timeout while @actor.busy? raise Exception.new("Timed out") if giveup < Time.now sleep(0.1) end end
links()
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 37 def links() lnk = Link.new(@name, nil, nil) lnk.instance_variable_set(:@target, self) { nil => lnk } end
log_msg(level, msg, fn)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 79 def log_msg(level, msg, fn) @history << Action.new(:log, Box.new([level, msg, fn])) end
queue_count()
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 43 def queue_count() 0 end
receive(op, box)
click to toggle source
Calls perform on the actor instance
# File lib/oflow/test/actorwrap.rb, line 48 def receive(op, box) if @starting @before << [op, box] else begin @actor.perform(op, box) rescue Exception => e handle_error(e) end end nil end
reset()
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 25 def reset() @history = [] end
ship(dest, box)
click to toggle source
Task
API that adds entry to history.
# File lib/oflow/test/actorwrap.rb, line 75 def ship(dest, box) @history << Action.new(dest, box) end
state()
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 33 def state() @state end
warn(msg)
click to toggle source
# File lib/oflow/test/actorwrap.rb, line 95 def warn(msg) log_msg(:warn, msg, full_name()) end