Class: RailsWorkflow::EventManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_workflow/event_manager.rb

Overview

This manager controls events processing. Searches matching event operations for a given event and merges event context to matched event operations.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag, context = {}) ⇒ EventManager

Returns a new instance of EventManager.



13
14
15
16
# File 'lib/rails_workflow/event_manager.rb', line 13

def initialize(tag, context = {})
  @tag = tag
  @context = context
end

Class Method Details

.create_event(tag, context = {}) ⇒ Object



8
9
10
# File 'lib/rails_workflow/event_manager.rb', line 8

def create_event(tag, context = {})
  new(tag, context).handle
end

Instance Method Details

#handleObject



18
19
20
21
22
23
24
25
26
# File 'lib/rails_workflow/event_manager.rb', line 18

def handle
  event_operations.each do |event_operation|
    next if not_matches(event_operation)

    process_multiple_event(event_operation)
    event_operation.data.merge!(@context)
    event_operation.complete
  end
end