Class: BatchApi::Processor::Sequential

Inherits:
Object
  • Object
show all
Defined in:
lib/batch_api/processor/sequential.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Sequential

Public: initialize with the app.



5
6
7
# File 'lib/batch_api/processor/sequential.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Public: execute all operations sequentially.

ops - a set of BatchApi::Operations options - a set of options

Returns an array of BatchApi::Response objects.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/batch_api/processor/sequential.rb', line 15

def call(env)
  env[:ops].collect do |op|
    # set the current op
    env[:op] = op

    # execute the individual request inside the operation-specific
    # middeware, then clear out the current op afterward
    middleware = InternalMiddleware.operation_stack
    middleware.call(env).tap {|r| env.delete(:op) }
  end
end