Module: TestProf::EventProf::CustomEvents

Defined in:
lib/test_prof/event_prof/custom_events.rb

Overview

Registers and activates custom events (which require patches).

Class Method Summary collapse

Class Method Details

.activate_all(events) ⇒ Object



13
14
15
16
# File 'lib/test_prof/event_prof/custom_events.rb', line 13

def activate_all(events)
  events = events.split(",")
  events.each { |event| try_activate(event) }
end

.register(event, &block) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
# File 'lib/test_prof/event_prof/custom_events.rb', line 8

def register(event, &block)
  raise ArgumentError, "Block is required!" unless block
  registrations[event] = block
end

.try_activate(event) ⇒ Object



18
19
20
21
# File 'lib/test_prof/event_prof/custom_events.rb', line 18

def try_activate(event)
  return unless registrations.key?(event)
  registrations.delete(event).call
end