Class: QED::Evaluator
Overview
Demonstrandum Evaluator is responsible for running demo scripts.
Instance Attribute Summary collapse
-
#demo ⇒ Demo
readonly
The Demo being evaluated.
-
#observers ⇒ Object
readonly
The observers.
Class Method Summary collapse
-
.run(demo, options = {}) ⇒ Object
Create new Evaluator instance and then run it.
Instance Method Summary collapse
-
#applique_observers ⇒ Object
Collect applique all the signal-based advice and wrap their evaluation in observable procedure calls.
-
#initialize(demo, options = {}) ⇒ Evaluator
constructor
Setup new evaluator instance.
-
#run ⇒ Object
Run the demo.
Constructor Details
#initialize(demo, options = {}) ⇒ Evaluator
Setup new evaluator instance.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/qed/evaluator.rb', line 26 def initialize(demo, ={}) @demo = demo @steps = demo.steps #@settings = options[:settings] @applique = [:applique] # BOOLEAN FLAG @observers = [:observers].to_a @observers += applique_observers @scope = [:scope] || Scope.new(demo) end |
Instance Attribute Details
#demo ⇒ Demo (readonly)
The Demo being evaluated.
57 58 59 |
# File 'lib/qed/evaluator.rb', line 57 def demo @demo end |
#observers ⇒ Object (readonly)
The observers.
61 62 63 |
# File 'lib/qed/evaluator.rb', line 61 def observers @observers end |
Class Method Details
.run(demo, options = {}) ⇒ Object
Create new Evaluator instance and then run it.
10 11 12 |
# File 'lib/qed/evaluator.rb', line 10 def self.run(demo, ={}) new(demo, ).run end |
Instance Method Details
#applique_observers ⇒ Object
Collect applique all the signal-based advice and wrap their evaluation in observable procedure calls.
42 43 44 45 46 47 48 49 50 |
# File 'lib/qed/evaluator.rb', line 42 def applique_observers demo = @demo demo.applique.map do |a| Proc.new do |type, *args| proc = a.__signals__[type.to_sym] @scope.instance_exec(*args, &proc) if proc end end end |
#run ⇒ Object
Run the demo.
65 66 67 68 69 70 71 72 73 |
# File 'lib/qed/evaluator.rb', line 65 def run advise!(:before_demo, @demo) begin advise!(:demo, @demo) run_steps ensure advise!(:after_demo, @demo) end end |