class ActiveRecord::Sharding::AllShardsInParallel

Public Class Methods

new(shards) click to toggle source
# File lib/active_record/sharding/all_shards_in_parallel.rb, line 7
def initialize(shards)
  @shards = shards
end

Public Instance Methods

each(&block) click to toggle source
# File lib/active_record/sharding/all_shards_in_parallel.rb, line 23
def each(&block)
  map(&block) if block_given?
  self
end
flat_map(&block) click to toggle source
# File lib/active_record/sharding/all_shards_in_parallel.rb, line 19
def flat_map(&block)
  map(&block).flatten
end
map() { |model| ... } click to toggle source
# File lib/active_record/sharding/all_shards_in_parallel.rb, line 11
def map(&_block)
  commands = @shards.map do |model|
    Expeditor::Command.new { model.connection_pool.with_connection { yield model } }
  end
  commands.each(&:start)
  commands.map(&:get)
end