Class: ActiveRecordShards::ConnectionSwitcher::MasterSlaveProxy
- Inherits:
-
Object
- Object
- ActiveRecordShards::ConnectionSwitcher::MasterSlaveProxy
- Defined in:
- lib/active_record_shards/connection_switcher.rb
Instance Method Summary collapse
-
#initialize(target, which) ⇒ MasterSlaveProxy
constructor
A new instance of MasterSlaveProxy.
-
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing.
Constructor Details
#initialize(target, which) ⇒ MasterSlaveProxy
Returns a new instance of MasterSlaveProxy.
203 204 205 206 |
# File 'lib/active_record_shards/connection_switcher.rb', line 203 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/MethodMissingSuper, Style/MissingRespondToMissing
208 209 210 |
# File 'lib/active_record_shards/connection_switcher.rb', line 208 def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing @target.on_master_or_slave(@which) { @target.send(method, *args, &block) } end |