Sha256: 103647cf7c7a26df5b0be334c16541eebe80b2b2f78c0974980b847610fc2b60

Contents?: true

Size: 369 Bytes

Versions: 3

Compression:

Stored size: 369 Bytes

Contents

module Twitter
  module Utils
    class << self
      def parallel_map(enumerable)
        # Don't bother spawning a new thread if there's only one item
        if enumerable.count == 1
          enumerable.map { |object| yield object }
        else
          enumerable.map { |object| Thread.new { yield object } }.map(&:value)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
twitter-5.4.1 lib/twitter/utils.rb
twitter-5.4.0 lib/twitter/utils.rb
twitter-5.3.1 lib/twitter/utils.rb