Module: Concurrent::OptionsParser
Overview
A mixin module for parsing options hashes related to gem-level configuration.
Instance Method Summary collapse
- #get_arguments_from(opts = {}) ⇒ Object
-
#get_executor_from(opts = {}) ⇒ Executor?
Get the requested ‘Executor` based on the values set in the options hash.
-
#get_operation_executor_from(opts = {}) ⇒ Executor
Get the requested ‘Executor` based on the values set in the options hash.
-
#get_task_executor_from(opts = {}) ⇒ Executor
Get the requested ‘Executor` based on the values set in the options hash.
Instance Method Details
#get_arguments_from(opts = {}) ⇒ Object
26 27 28 |
# File 'lib/concurrent/options_parser.rb', line 26 def get_arguments_from(opts = {}) [*opts.fetch(:args, [])] end |
#get_executor_from(opts = {}) ⇒ Executor?
Get the requested ‘Executor` based on the values set in the options hash.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/concurrent/options_parser.rb', line 14 def get_executor_from(opts = {}) if opts[:executor] opts[:executor] elsif opts[:operation] == true || opts[:task] == false Concurrent.configuration.global_operation_pool elsif opts[:operation] == false || opts[:task] == true Concurrent.configuration.global_task_pool else nil end end |
#get_operation_executor_from(opts = {}) ⇒ Executor
Get the requested ‘Executor` based on the values set in the options hash.
46 47 48 |
# File 'lib/concurrent/options_parser.rb', line 46 def get_operation_executor_from(opts = {}) opts[:operation_executor] || opts[:executor] || Concurrent.configuration.global_operation_pool end |
#get_task_executor_from(opts = {}) ⇒ Executor
Get the requested ‘Executor` based on the values set in the options hash.
36 37 38 |
# File 'lib/concurrent/options_parser.rb', line 36 def get_task_executor_from(opts = {}) opts[:task_executor] || opts[:executor] || Concurrent.configuration.global_task_pool end |