Class: ActiveRecordHostPool::ConnectionProxy

Inherits:
Delegator
  • Object
show all
Defined in:
lib/active_record_host_pool/connection_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(cx, database) ⇒ ConnectionProxy

Returns a new instance of ConnectionProxy.



7
8
9
10
11
# File 'lib/active_record_host_pool/connection_proxy.rb', line 7

def initialize(cx, database)
  super(cx)
  @cx = cx
  @database = database
end

Instance Method Details

#__getobj__Object



13
14
15
16
# File 'lib/active_record_host_pool/connection_proxy.rb', line 13

def __getobj__
  @cx._host_pool_current_database = @database
  @cx
end

#__setobj__(cx) ⇒ Object



18
19
20
# File 'lib/active_record_host_pool/connection_proxy.rb', line 18

def __setobj__(cx)
  @cx = cx
end

#classObject

this is bad. I know. but it allows folks who class_eval on connection.class to do so



27
28
29
# File 'lib/active_record_host_pool/connection_proxy.rb', line 27

def class
  @cx.class
end

#expects(*args) ⇒ Object



31
32
33
# File 'lib/active_record_host_pool/connection_proxy.rb', line 31

def expects(*args)
  @cx.send(:expects, *args)
end

#private_methods(all = true) ⇒ Object



40
41
42
# File 'lib/active_record_host_pool/connection_proxy.rb', line 40

def private_methods(all=true)
  __getobj__.private_methods(all) | super
end

#respond_to_missing?(m, include_private) ⇒ Boolean

Override Delegator#respond_to_missing? to allow private methods to be accessed without warning

Returns:

  • (Boolean)


36
37
38
# File 'lib/active_record_host_pool/connection_proxy.rb', line 36

def respond_to_missing?(m, include_private)
  __getobj__.respond_to?(m, include_private)
end

#send(symbol, *args, &blk) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/active_record_host_pool/connection_proxy.rb', line 44

def send(symbol, *args, &blk)
  if respond_to?(symbol, true) && !__getobj__.respond_to?(symbol, true)
    super
  else
    __getobj__.send(symbol, *args, &blk)
  end
end

#unproxiedObject



22
23
24
# File 'lib/active_record_host_pool/connection_proxy.rb', line 22

def unproxied
  @cx
end