module Arproxy

Constants

VERSION

Public Instance Methods

clear_configuration() click to toggle source
# File lib/arproxy.rb, line 12
def clear_configuration
  @config = Config.new
end
configure() { |config| ... } click to toggle source
# File lib/arproxy.rb, line 16
def configure
  clear_configuration unless @config
  yield @config
end
disable!() click to toggle source
# File lib/arproxy.rb, line 37
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!() click to toggle source
# File lib/arproxy.rb, line 21
def enable!
  if enable?
    Arproxy.logger.warn "Arproxy has been already enabled"
    return
  end

  unless @config
    raise Arproxy::Error, "Arproxy should be configured"
  end

  @proxy_chain = ProxyChain.new @config
  @proxy_chain.enable!

  @enabled = true
end
enable?() click to toggle source
# File lib/arproxy.rb, line 50
def enable?
  !!@enabled
end
logger() click to toggle source
# File lib/arproxy.rb, line 62
def logger
  @logger ||= begin
                @config && @config.logger ||
                  defined?(::Rails) && ::Rails.logger ||
                  ::Logger.new(STDOUT)
              end
end
proxy_chain() click to toggle source
# File lib/arproxy.rb, line 70
def proxy_chain
  @proxy_chain
end
reenable!() click to toggle source
# File lib/arproxy.rb, line 54
def reenable!
  if enable?
    @proxy_chain.reenable!
  else
    enable!
  end
end