Module: TwitterWithAutoPagination::Parallel
- Included in:
- Client
- Defined in:
- lib/twitter_with_auto_pagination/parallel.rb
Defined Under Namespace
Classes: Arguments
Instance Method Summary collapse
Instance Method Details
#parallel(options = {}) {|batch| ... } ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/twitter_with_auto_pagination/parallel.rb', line 6 def parallel( = {}, &block) batch = Arguments.new yield(batch) in_threads = .fetch(:in_threads, batch.size) ::Parallel.map_with_index(batch, in_threads: in_threads) do |args, i| {i: i, result: send(*args)} end.sort_by { |q| q[:i] }.map { |q| q[:result] } end |