Class: Slaver::Proxy
- Inherits:
-
Object
show all
- Includes:
- Singleton
- Defined in:
- lib/slaver/proxy.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
34
35
36
|
# File 'lib/slaver/proxy.rb', line 34
def method_missing(method, *args, &block)
safe_connection.send(method, *args, &block)
end
|
Instance Attribute Details
#connection_pool ⇒ Object
Returns the value of attribute connection_pool.
5
6
7
|
# File 'lib/slaver/proxy.rb', line 5
def connection_pool
@connection_pool
end
|
#klass ⇒ Object
Returns the value of attribute klass.
5
6
7
|
# File 'lib/slaver/proxy.rb', line 5
def klass
@klass
end
|
Instance Method Details
#clear_active_connections! ⇒ Object
22
23
24
|
# File 'lib/slaver/proxy.rb', line 22
def clear_active_connections!
connection_pool.release_connection
end
|
#clear_all_connections! ⇒ Object
18
19
20
|
# File 'lib/slaver/proxy.rb', line 18
def clear_all_connections!
connection_pool.disconnect!
end
|
#connected? ⇒ Boolean
14
15
16
|
# File 'lib/slaver/proxy.rb', line 14
def connected?
connection_pool.connected?
end
|
#for_config(klass, config_name) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/slaver/proxy.rb', line 7
def for_config(klass, config_name)
@klass = klass
@connection_pool = klass.pools[config_name]
self
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
38
39
40
|
# File 'lib/slaver/proxy.rb', line 38
def respond_to_missing?(method, include_private = false)
safe_connection.respond_to?(method, include_private) || super
end
|
#safe_connection ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/slaver/proxy.rb', line 26
def safe_connection
connection_pool.automatic_reconnect = true
if !connection_pool.connected? && klass.connection_without_proxy.query_cache_enabled
connection_pool.connection.enable_query_cache!
end
connection_pool.connection
end
|