Class: Edrive::ProcessorDispatcher
- Inherits:
-
Dispatcher
- Object
- Dispatcher
- Edrive::ProcessorDispatcher
- Defined in:
- lib/edrive/processor_dispatcher.rb
Constant Summary collapse
- DEFINED_EVENT =
Returns defined event symbols.
i[before_process after_process].freeze
- DEFAULT_PROCESSOR_PROCESS =
Returns default processor process symbol.
:process
Instance Attribute Summary collapse
-
#processor ⇒ Object
Returns the value of attribute processor.
-
#processor_process ⇒ Object
Returns the value of attribute processor_process.
Instance Method Summary collapse
-
#dispatch_all(use_result = true) ⇒ Mixed
Dispatch all events.
-
#dispatch_processor_process(*args) ⇒ Mixed
Dispach processor process.
-
#initialize(processor, processor_process = DEFAULT_PROCESSOR_PROCESS) ⇒ ProcessorDispatcher
constructor
Initialize.
-
#subscribe(event, handler = nil, &block) ⇒ Array
subscribe handler (proc, lambda, block).
Methods inherited from Dispatcher
#clear!, #clear_all!, #dispatch, #dispatch_with_data, #handlers
Constructor Details
#initialize(processor, processor_process = DEFAULT_PROCESSOR_PROCESS) ⇒ ProcessorDispatcher
Initialize
22 23 24 25 26 |
# File 'lib/edrive/processor_dispatcher.rb', line 22 def initialize(processor, processor_process = DEFAULT_PROCESSOR_PROCESS) super() @processor = processor @processor_process = processor_process end |
Instance Attribute Details
#processor ⇒ Object
Returns the value of attribute processor.
11 12 13 |
# File 'lib/edrive/processor_dispatcher.rb', line 11 def processor @processor end |
#processor_process ⇒ Object
Returns the value of attribute processor_process.
11 12 13 |
# File 'lib/edrive/processor_dispatcher.rb', line 11 def processor_process @processor_process end |
Instance Method Details
#dispatch_all(use_result = true) ⇒ Mixed
Dispatch all events
42 43 44 45 46 47 48 49 50 |
# File 'lib/edrive/processor_dispatcher.rb', line 42 def dispatch_all(use_result = true) dispatch(DEFINED_EVENT[0]) if use_result result = dispatch_processor_process return dispatch_with_data(DEFINED_EVENT[1], result) end dispatch_processor_process dispatch(DEFINED_EVENT[1]) end |
#dispatch_processor_process(*args) ⇒ Mixed
Dispach processor process
55 56 57 |
# File 'lib/edrive/processor_dispatcher.rb', line 55 def dispatch_processor_process(*args) processor.send(processor_process, *args) end |
#subscribe(event, handler = nil, &block) ⇒ Array
subscribe handler (proc, lambda, block)
34 35 36 37 |
# File 'lib/edrive/processor_dispatcher.rb', line 34 def subscribe(event, handler = nil, &block) undefined_event_protect(event) super end |