Class: ActiveRecord::Turntable::Mixer::Fader::InsertShardsMergeResult

Inherits:
ActiveRecord::Turntable::Mixer::Fader show all
Defined in:
lib/active_record/turntable/mixer/fader/insert_shards_merge_result.rb

Instance Attribute Summary

Attributes inherited from ActiveRecord::Turntable::Mixer::Fader

#called_method, #query, #shards_query_hash

Instance Method Summary collapse

Methods inherited from ActiveRecord::Turntable::Mixer::Fader

#initialize

Constructor Details

This class inherits a constructor from ActiveRecord::Turntable::Mixer::Fader

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_record/turntable/mixer/fader/insert_shards_merge_result.rb', line 5

def execute
  if @shards_query_hash.size == 1
    @proxy.shards_transaction(@shards_query_hash.keys) do
      shard, query = @shards_query_hash.first
      shard.connection.send(@called_method, query, *@args, &@block)
    end
  else
    @proxy.shards_transaction(@shards_query_hash.keys) do
      @shards_query_hash.each do |shard, query|
        args    = @args.dup
        args[4] = args[4].dup if args[4].present?
        shard.connection.send(@called_method, query, *args, &@block)
      end
    end
  end
end