Class: Wisper::Minitest::EventRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/wisper/minitest/event_recorder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventRecorder

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

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/wisper/minitest/event_recorder.rb', line 6

def args
  @args
end

#broadcast_eventsObject (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_nameObject (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

Returns:

  • (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

Returns:

  • (Boolean)


12
13
14
# File 'lib/wisper/minitest/event_recorder.rb', line 12

def respond_to?(method_name)
  true
end