Class: HelpfulUtils::EventMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/helpful_utils/patching_utils/event_machine.rb

Constant Summary collapse

@@actions_and_blocks =
{}

Class Method Summary collapse

Class Method Details

.method_missing(method_symbol, *parameters) ⇒ Object

:nodoc:



24
25
26
27
28
29
30
# File 'lib/helpful_utils/patching_utils/event_machine.rb', line 24

def method_missing(method_symbol, *parameters)#:nodoc:
  if @@actions_and_blocks.has_key? method_symbol
    @@actions_and_blocks[method_symbol].each do |action|
      action.call *parameters
    end
  end
end

.subscribe(event_symbol, &block) ⇒ Object



32
33
34
35
# File 'lib/helpful_utils/patching_utils/event_machine.rb', line 32

def subscribe(event_symbol, &block)
  @@actions_and_blocks[event_symbol] ||= []
  @@actions_and_blocks[event_symbol] << block
end