Class: DeployPin::ParallelWrapper::ParallelRunner
- Inherits:
-
Object
- Object
- DeployPin::ParallelWrapper::ParallelRunner
- Defined in:
- lib/deploy_pin/parallel_wrapper.rb
Overview
:reek:TooManyInstanceVariables
Instance Method Summary collapse
-
#initialize(method_name, *args, &db_block) ⇒ ParallelRunner
constructor
A new instance of ParallelRunner.
- #run ⇒ Object
Constructor Details
#initialize(method_name, *args, &db_block) ⇒ ParallelRunner
Returns a new instance of ParallelRunner.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/deploy_pin/parallel_wrapper.rb', line 23 def initialize(method_name, *args, &db_block) @method_name = method_name @db_block = db_block if args.last.is_a?(Hash) && args.last.key?(:timeout) @timeout_args = args.pop prepare_timeout_args end @parallel_args = args end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/deploy_pin/parallel_wrapper.rb', line 35 def run raise 'You must provide at least one argument for parallel methods' if parallel_args.empty? Parallel.send(parallel_method_name, *parallel_args) do |*block_args| ActiveRecord::Base.connection_pool.with_connection do DeployPin::Database.execute_with_timeout(timeout, **timeout_params) do db_block.call(*block_args) end end end end |