Class: OFlow::Test::ActorWrap

Inherits:
Object
  • Object
show all
Defined in:
lib/oflow/test/actorwrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @name = name
  @actor = actor_class.new(self, options)
  @history = []
end

Instance Attribute Details

#actorObject (readonly)

Returns the value of attribute actor.



6
7
8
# File 'lib/oflow/test/actorwrap.rb', line 6

def actor
  @actor
end

#historyObject (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

#nameObject

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_nameObject



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

#resetObject



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