Module: SwitchConnection::Relation::MonkeyPatch

Defined in:
lib/switch_connection/connection_routing.rb

Instance Method Summary collapse

Instance Method Details

#calculate(*args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/switch_connection/connection_routing.rb', line 7

def calculate(*args, &block)
  if @klass.switch_point_proxy && !lock_value && @klass.connection.open_transactions.zero?
    @klass.with_slave do
      super
    end
  else
    super
  end
end

#exists?(*args, &block) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
# File 'lib/switch_connection/connection_routing.rb', line 17

def exists?(*args, &block)
  if @klass.switch_point_proxy && !lock_value && @klass.connection.open_transactions.zero?
    @klass.with_slave do
      super
    end
  else
    super
  end
end

#pluck(*args, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/switch_connection/connection_routing.rb', line 27

def pluck(*args, &block)
  if @klass.switch_point_proxy && !lock_value && @klass.connection.open_transactions.zero?
    @klass.with_slave do
      super
    end
  else
    super
  end
end