module TwitterWithAutoPagination::Parallel

Public Instance Methods

fetch_parallelly(signatures) click to toggle source

Deprecated

{method: :friends, args: ['ts_3156', …], {…}
# File lib/twitter_with_auto_pagination/parallel.rb, line 38
def fetch_parallelly(signatures)
  ::Parallel.map_with_index(signatures, in_threads: signatures.size) do |signature, i|
    {i: i, result: send(signature[:method], *signature[:args])}
  end.sort_by { |q| q[:i] }.map { |q| q[:result] }
end
parallel(options = {}) { |batch| ... } click to toggle source
# File lib/twitter_with_auto_pagination/parallel.rb, line 6
def parallel(options = {}, &block)
  batch = Arguments.new
  yield(batch)

  in_threads = options.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