Class: ActiveRecordShards::ConnectionSwitcher::MasterSlaveProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_shards/connection_switcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(target, which) ⇒ MasterSlaveProxy

Returns a new instance of MasterSlaveProxy.



196
197
198
199
# File 'lib/active_record_shards/connection_switcher.rb', line 196

def initialize(target, which)
  @target = target
  @which = which
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

rubocop:disable Style/MethodMissing



201
202
203
# File 'lib/active_record_shards/connection_switcher.rb', line 201

def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissing
  @target.on_master_or_slave(@which) { @target.send(method, *args, &block) }
end