Class: TwoPercent::BulkProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/two_percent/bulk_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(operations) ⇒ BulkProcessor

Returns a new instance of BulkProcessor.



5
6
7
# File 'lib/two_percent/bulk_processor.rb', line 5

def initialize(operations)
  @operations = operations
end

Instance Method Details

#dispatch(event_handler = EventHandler) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/two_percent/bulk_processor.rb', line 9

def dispatch(event_handler = EventHandler)
  @operations.each do |operation|
    resource, id = parse_path(operation[:path])
    attrs = { resource: resource, id: id, params: operation[:data] }.compact
    event_handler.dispatch(operation[:method], **attrs)
  end
end