Class: BatchApi::Processor
- Inherits:
-
Object
- Object
- BatchApi::Processor
- Defined in:
- lib/batch_api/processor.rb,
lib/batch_api/processor/executor.rb,
lib/batch_api/processor/sequential.rb
Defined Under Namespace
Classes: Executor, Sequential
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#ops ⇒ Object
readonly
Returns the value of attribute ops.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#execute! ⇒ Object
Public: run the batch operations according to the appropriate strategy.
-
#initialize(request, app) ⇒ Processor
constructor
Public: create a new Processor.
-
#strategy ⇒ Object
Public: the processing strategy to use, based on the options provided in BatchApi setup and the request.
Constructor Details
#initialize(request, app) ⇒ Processor
Public: create a new Processor.
env - a Rack environment hash app - a Rack application
Raises OperationLimitExceeded if more operations are requested than allowed by the BatchApi configuration. Raises Errors::BadOptionError if other provided options are invalid. Raises ArgumentError if no operations are provided (nil or []).
Returns the new Processor instance.
19 20 21 22 23 24 25 |
# File 'lib/batch_api/processor.rb', line 19 def initialize(request, app) @app = app @request = request @env = request.env @ops = self.process_ops @options = self. end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/batch_api/processor.rb', line 6 def app @app end |
#ops ⇒ Object (readonly)
Returns the value of attribute ops.
6 7 8 |
# File 'lib/batch_api/processor.rb', line 6 def ops @ops end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/batch_api/processor.rb', line 6 def @options end |
Instance Method Details
#execute! ⇒ Object
Public: run the batch operations according to the appropriate strategy.
Returns a set of BatchResponses
37 38 39 40 |
# File 'lib/batch_api/processor.rb', line 37 def execute! stack = InternalMiddleware.batch_stack(self) format_response(stack.call(middleware_env)) end |
#strategy ⇒ Object
Public: the processing strategy to use, based on the options provided in BatchApi setup and the request. Currently only Sequential is supported.
30 31 32 |
# File 'lib/batch_api/processor.rb', line 30 def strategy BatchApi::Processor::Sequential end |