Class: ActiveRecordHostPool::ConnectionProxy
- Inherits:
-
Delegator
- Object
- Delegator
- ActiveRecordHostPool::ConnectionProxy
- Defined in:
- lib/active_record_host_pool/connection_proxy.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #__getobj__ ⇒ Object
- #__setobj__(cx) ⇒ Object
-
#class ⇒ Object
this is bad.
- #expects(*args) ⇒ Object
- #hash ⇒ Object
-
#initialize(cx, database) ⇒ ConnectionProxy
constructor
A new instance of ConnectionProxy.
- #private_methods(all = true) ⇒ Object
-
#respond_to_missing?(name, include_private) ⇒ Boolean
Override Delegator#respond_to_missing? to allow private methods to be accessed without warning.
- #send(symbol) ⇒ Object
- #unproxied ⇒ Object
Constructor Details
#initialize(cx, database) ⇒ ConnectionProxy
Returns a new instance of ConnectionProxy.
10 11 12 13 14 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 10 def initialize(cx, database) super(cx) @cx = cx @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
9 10 11 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 9 def database @database end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
55 56 57 58 59 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 55 def ==(other) self.class == other.class && other.respond_to?(:unproxied) && @cx == other.unproxied && other.respond_to?(:database) && @database == other.database end |
#__getobj__ ⇒ Object
16 17 18 19 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 16 def __getobj__ @cx._host_pool_desired_database = @database @cx end |
#__setobj__(cx) ⇒ Object
21 22 23 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 21 def __setobj__(cx) @cx = cx end |
#class ⇒ Object
this is bad. I know. but it allows folks who class_eval on connection.class to do so
30 31 32 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 30 def class @cx.class end |
#expects(*args) ⇒ Object
34 35 36 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 34 def expects(*args) @cx.send(:expects, *args) end |
#hash ⇒ Object
63 64 65 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 63 def hash [self.class, @cx, @database].hash end |
#private_methods(all = true) ⇒ Object
43 44 45 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 43 def private_methods(all = true) __getobj__.private_methods(all) | super end |
#respond_to_missing?(name, include_private) ⇒ Boolean
Override Delegator#respond_to_missing? to allow private methods to be accessed without warning
39 40 41 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 39 def respond_to_missing?(name, include_private) __getobj__.respond_to?(name, include_private) end |
#send(symbol) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 47 def send(symbol, ...) if respond_to?(symbol, true) && !__getobj__.respond_to?(symbol, true) super else __getobj__.send(symbol, ...) end end |
#unproxied ⇒ Object
25 26 27 |
# File 'lib/active_record_host_pool/connection_proxy.rb', line 25 def unproxied @cx end |