Class: ConAir::ConnectionHandler
- Inherits:
-
ActiveRecord::ConnectionAdapters::ConnectionHandler
- Object
- ActiveRecord::ConnectionAdapters::ConnectionHandler
- ConAir::ConnectionHandler
- Defined in:
- lib/con_air/connection_handler.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#hijacked_spec ⇒ Object
readonly
Returns the value of attribute hijacked_spec.
-
#swap_class ⇒ Object
readonly
Returns the value of attribute swap_class.
Instance Method Summary collapse
- #establish_connection(name, spec) ⇒ Object
- #exist?(config, klass) ⇒ Boolean
-
#initialize(swap_class, hijacked_spec, pools = {}) ⇒ ConnectionHandler
constructor
A new instance of ConnectionHandler.
Constructor Details
#initialize(swap_class, hijacked_spec, pools = {}) ⇒ ConnectionHandler
Returns a new instance of ConnectionHandler.
7 8 9 10 11 12 |
# File 'lib/con_air/connection_handler.rb', line 7 def initialize(swap_class, hijacked_spec, pools = {}) super(pools) @hijacked_spec = hijacked_spec @swap_class = swap_class end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
3 4 5 |
# File 'lib/con_air/connection_handler.rb', line 3 def active @active end |
#hijacked_spec ⇒ Object (readonly)
Returns the value of attribute hijacked_spec.
4 5 6 |
# File 'lib/con_air/connection_handler.rb', line 4 def hijacked_spec @hijacked_spec end |
#swap_class ⇒ Object (readonly)
Returns the value of attribute swap_class.
5 6 7 |
# File 'lib/con_air/connection_handler.rb', line 5 def swap_class @swap_class end |
Instance Method Details
#establish_connection(name, spec) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/con_air/connection_handler.rb', line 14 def establish_connection(name, spec) if name == swap_class.name @connection_pools[@hijacked_spec] ||= ActiveRecord::ConnectionAdapters::ConnectionPool.new(@hijacked_spec) @class_to_pool[name] = @connection_pools[@hijacked_spec] else super end end |
#exist?(config, klass) ⇒ Boolean
23 24 25 |
# File 'lib/con_air/connection_handler.rb', line 23 def exist?(config, klass) hijacked_spec.config == config && swap_class == klass end |