Class: OFlow::Test::ActorWrap
- Inherits:
-
Object
- Object
- OFlow::Test::ActorWrap
- Defined in:
- lib/oflow/test/actorwrap.rb
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#history ⇒ Object
readonly
Array of Actions.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #full_name ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(name, actor_class, options = {}) ⇒ ActorWrap
constructor
A new instance of ActorWrap.
- #log_msg(level, msg, fn) ⇒ Object
-
#receive(op, box) ⇒ Object
Calls perform on the actor instance.
- #reset ⇒ Object
-
#ship(dest, box) ⇒ Object
Task API that adds entry to history.
- #warn(msg) ⇒ Object
Constructor Details
#initialize(name, actor_class, options = {}) ⇒ ActorWrap
Returns a new instance of ActorWrap.
12 13 14 15 16 |
# File 'lib/oflow/test/actorwrap.rb', line 12 def initialize(name, actor_class, ={}) @name = name @actor = actor_class.new(self, ) @history = [] end |
Instance Attribute Details
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
6 7 8 |
# File 'lib/oflow/test/actorwrap.rb', line 6 def actor @actor end |
#history ⇒ Object (readonly)
Array of Actions. Log entries appear with a destination of :log.
10 11 12 |
# File 'lib/oflow/test/actorwrap.rb', line 10 def history @history end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/oflow/test/actorwrap.rb', line 7 def name @name end |
Instance Method Details
#debug(msg) ⇒ Object
40 41 42 |
# File 'lib/oflow/test/actorwrap.rb', line 40 def debug(msg) log_msg(:debug, msg, full_name()) end |
#error(msg) ⇒ Object
48 49 50 |
# File 'lib/oflow/test/actorwrap.rb', line 48 def error(msg) log_msg(:error, msg, full_name()) end |
#fatal(msg) ⇒ Object
56 57 58 |
# File 'lib/oflow/test/actorwrap.rb', line 56 def fatal(msg) log_msg(:fatal, msg, full_name()) end |
#full_name ⇒ Object
22 23 24 |
# File 'lib/oflow/test/actorwrap.rb', line 22 def full_name() ":test:#{@name}" end |
#info(msg) ⇒ Object
44 45 46 |
# File 'lib/oflow/test/actorwrap.rb', line 44 def info(msg) log_msg(:info, msg, full_name()) end |
#log_msg(level, msg, fn) ⇒ Object
36 37 38 |
# File 'lib/oflow/test/actorwrap.rb', line 36 def log_msg(level, msg, fn) @history << Action.new(:log, Box.new([level, msg, fn])) end |
#receive(op, box) ⇒ Object
Calls perform on the actor instance
27 28 29 |
# File 'lib/oflow/test/actorwrap.rb', line 27 def receive(op, box) @actor.perform(op, box) end |
#reset ⇒ Object
18 19 20 |
# File 'lib/oflow/test/actorwrap.rb', line 18 def reset() @history = [] end |
#ship(dest, box) ⇒ Object
Task API that adds entry to history.
32 33 34 |
# File 'lib/oflow/test/actorwrap.rb', line 32 def ship(dest, box) @history << Action.new(dest, box) end |
#warn(msg) ⇒ Object
52 53 54 |
# File 'lib/oflow/test/actorwrap.rb', line 52 def warn(msg) log_msg(:warn, msg, full_name()) end |