Class: Dilation::TestSupport::Handler
- Inherits:
-
Object
- Object
- Dilation::TestSupport::Handler
- Defined in:
- lib/dilation/test_support/handler.rb
Overview
A handler that can be used in tests to confirm that events are hooked up
Instance Attribute Summary collapse
-
#count ⇒ Number
readonly
The number of times triggered.
Instance Method Summary collapse
-
#call ⇒ Number
Trigger this handler.
-
#initialize ⇒ Handler
constructor
A new instance of Handler.
-
#triggered? ⇒ Boolean
True if this handler has been called.
Constructor Details
#initialize ⇒ Handler
Returns a new instance of Handler.
22 23 24 |
# File 'lib/dilation/test_support/handler.rb', line 22 def initialize @count = 0 end |
Instance Attribute Details
#count ⇒ Number (readonly)
Returns the number of times triggered.
20 21 22 |
# File 'lib/dilation/test_support/handler.rb', line 20 def count @count end |
Instance Method Details
#call ⇒ Number
Note:
increments the counter
Trigger this handler
30 31 32 |
# File 'lib/dilation/test_support/handler.rb', line 30 def call @count += 1 end |
#triggered? ⇒ Boolean
Returns true if this handler has been called.
35 36 37 |
# File 'lib/dilation/test_support/handler.rb', line 35 def triggered? @count > 0 end |