Class: BatchApi::Processor
- Inherits:
-
Object
- Object
- BatchApi::Processor
- Defined in:
- lib/batch_api/processor.rb,
lib/batch_api/processor/strategies/sequential.rb
Defined Under Namespace
Modules: Strategies Classes: BadOptionError, NoOperationsError, OperationLimitExceeded
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 BadOptionError if other provided options are invalid. Raises ArgumentError if no operations are provided (nil or []).
Returns the new Processor instance.
27 28 29 30 31 32 33 34 35 |
# File 'lib/batch_api/processor.rb', line 27 def initialize(request, app) @app = app @request = request @env = request.env @ops = self.process_ops @options = self. @start_time = Time.now.to_i end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
14 15 16 |
# File 'lib/batch_api/processor.rb', line 14 def app @app end |
#ops ⇒ Object (readonly)
Returns the value of attribute ops.
14 15 16 |
# File 'lib/batch_api/processor.rb', line 14 def ops @ops end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/batch_api/processor.rb', line 14 def @options end |
Instance Method Details
#execute! ⇒ Object
Public: run the batch operations according to the appropriate strategy.
Returns a set of BatchResponses
47 48 49 |
# File 'lib/batch_api/processor.rb', line 47 def execute! format_response(strategy.execute!(@ops, @options)) 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.
40 41 42 |
# File 'lib/batch_api/processor.rb', line 40 def strategy BatchApi::Processor::Strategies::Sequential end |