Module: Arproxy
- Defined in:
- lib/arproxy.rb,
lib/arproxy/base.rb,
lib/arproxy/error.rb,
lib/arproxy/proxy.rb,
lib/arproxy/config.rb,
lib/arproxy/plugin.rb,
lib/arproxy/version.rb,
lib/arproxy/proxy_chain.rb,
lib/arproxy/query_context.rb,
lib/arproxy/proxy_chain_tail.rb,
lib/arproxy/connection_adapter_patch.rb
Defined Under Namespace
Modules: Plugin
Classes: Base, Config, ConnectionAdapterPatch, Error, Proxy, ProxyChain, ProxyChainTail, QueryContext
Constant Summary
collapse
- VERSION =
'1.0.0'
Class Method Summary
collapse
Class Method Details
.clear_configuration ⇒ Object
16
17
18
|
# File 'lib/arproxy.rb', line 16
def clear_configuration
@config = nil
end
|
20
21
22
23
|
# File 'lib/arproxy.rb', line 20
def configure
@config ||= Config.new
yield @config
end
|
.connection_adapter_patch ⇒ Object
78
79
80
|
# File 'lib/arproxy.rb', line 78
def connection_adapter_patch
@patch
end
|
.disable! ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/arproxy.rb', line 42
def disable!
unless enable?
Arproxy.logger.warn 'Arproxy is not enabled yet'
return
end
if @proxy_chain
@proxy_chain.disable!
@proxy_chain = nil
end
@enabled = false
end
|
.enable! ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/arproxy.rb', line 25
def enable!
if enable?
Arproxy.logger.warn 'Arproxy has already been enabled'
return
end
unless @config
raise Arproxy::Error, 'Arproxy has not been configured'
end
@patch = ConnectionAdapterPatch.new(@config.adapter_class)
@proxy_chain = ProxyChain.new(@config, @patch)
@proxy_chain.enable!
@enabled = true
end
|
.enable? ⇒ Boolean
56
57
58
|
# File 'lib/arproxy.rb', line 56
def enable?
!!@enabled
end
|
.logger ⇒ Object
68
69
70
71
72
|
# File 'lib/arproxy.rb', line 68
def logger
@logger ||= @config && @config.logger ||
defined?(::Rails) && ::Rails.logger ||
::Logger.new(STDOUT)
end
|
.proxy_chain ⇒ Object
74
75
76
|
# File 'lib/arproxy.rb', line 74
def proxy_chain
@proxy_chain
end
|
.reenable! ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/arproxy.rb', line 60
def reenable!
if enable?
@proxy_chain.reenable!
else
enable!
end
end
|