Class: QED::Advice

Inherits:
Object
  • Object
show all
Defined in:
lib/qed/advice.rb,
lib/qed/advice/events.rb

Overview

Advice

This class tracks advice defined by demo scripts and helpers. It is instantiated in Scope, so that the advice methods will have access to the same local binding and the scripts themselves.

Defined Under Namespace

Classes: Events

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAdvice

Returns a new instance of Advice.



19
20
21
22
# File 'lib/qed/advice.rb', line 19

def initialize
  @patterns = Patterns.new
  @events   = Events.new
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



17
18
19
# File 'lib/qed/advice.rb', line 17

def events
  @events
end

#patternsObject (readonly)

Returns the value of attribute patterns.



15
16
17
# File 'lib/qed/advice.rb', line 15

def patterns
  @patterns
end

Instance Method Details

#call(scope, type, *args) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/qed/advice.rb', line 24

def call(scope, type, *args)
  case type
  when :when
    @patterns.call(scope, *args)
  else
    @events.call(scope, type, *args)
  end
end