Class: Wisper::Minitest::EventRecorder
- Inherits:
-
Object
- Object
- Wisper::Minitest::EventRecorder
- Defined in:
- lib/wisper/minitest/event_recorder.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#broadcast_events ⇒ Object
readonly
Returns the value of attribute broadcast_events.
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
Instance Method Summary collapse
- #broadcast?(event_name, *args) ⇒ Boolean
-
#initialize ⇒ EventRecorder
constructor
A new instance of EventRecorder.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to?(method_name) ⇒ Boolean
Constructor Details
#initialize ⇒ EventRecorder
Returns a new instance of EventRecorder.
8 9 10 |
# File 'lib/wisper/minitest/event_recorder.rb', line 8 def initialize @broadcast_events = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
16 17 18 |
# File 'lib/wisper/minitest/event_recorder.rb', line 16 def method_missing(method_name, *args, &block) @broadcast_events << [method_name.to_s, *args] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/wisper/minitest/event_recorder.rb', line 6 def args @args end |
#broadcast_events ⇒ Object (readonly)
Returns the value of attribute broadcast_events.
4 5 6 |
# File 'lib/wisper/minitest/event_recorder.rb', line 4 def broadcast_events @broadcast_events end |
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
5 6 7 |
# File 'lib/wisper/minitest/event_recorder.rb', line 5 def event_name @event_name end |
Instance Method Details
#broadcast?(event_name, *args) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wisper/minitest/event_recorder.rb', line 20 def broadcast?(event_name, *args) @event_name = event_name @args = args if args.size > 0 @broadcast_events.include?([event_name.to_s, *args]) else @broadcast_events.map(&:first).include?(event_name.to_s) end end |
#respond_to?(method_name) ⇒ Boolean
12 13 14 |
# File 'lib/wisper/minitest/event_recorder.rb', line 12 def respond_to?(method_name) true end |