Class: Processor::EventProcessor
- Inherits:
-
Object
- Object
- Processor::EventProcessor
- Defined in:
- lib/processor/event_processor.rb
Instance Method Summary collapse
-
#initialize(processor, observers = []) ⇒ EventProcessor
constructor
A new instance of EventProcessor.
- #method_missing(method, *args) ⇒ Object
- #register(event, *data) ⇒ Object
Constructor Details
#initialize(processor, observers = []) ⇒ EventProcessor
Returns a new instance of EventProcessor.
3 4 5 6 |
# File 'lib/processor/event_processor.rb', line 3 def initialize(processor, observers = []) @observers = observers @processor = processor end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/processor/event_processor.rb', line 14 def method_missing(method, *args) register "before_#{method}", *args result = processor.public_send method, *args register "after_#{method}", result, *args result end |
Instance Method Details
#register(event, *data) ⇒ Object
8 9 10 11 12 |
# File 'lib/processor/event_processor.rb', line 8 def register(event, *data) observers.each do |observer| observer.update event.to_sym, processor, *data end end |