Module: AirbrakeAPI::Configuration

Included in:
AirbrakeAPI
Defined in:
lib/airbrake-api/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
:account,
:auth_token,
:secure,
:connection_options,
:adapter,
:user_agent,
:middleware]
DEFAULT_ADAPTER =
:net_http
DEFAULT_USER_AGENT =
"AirbrakeAPI Ruby Gem #{AirbrakeAPI::VERSION}"
DEFAULT_CONNECTION_OPTIONS =
{}
DEFAULT_MIDDLEWARE =
[
Faraday::Request::UrlEncoded,
AirbrakeAPI::Middleware::RaiseResponseError,
FaradayMiddleware::Mashify,
FaradayMiddleware::ParseXml,
AirbrakeAPI::Middleware::ScrubResponse,
AirbrakeAPI::Middleware::RaiseServerError]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


31
32
33
# File 'lib/airbrake-api/configuration.rb', line 31

def self.extended(base)
  base.reset
end

Instance Method Details

#account_pathObject


50
51
52
# File 'lib/airbrake-api/configuration.rb', line 50

def 
  "#{protocol}://#{@account}.airbrake.io"
end

#configure(options = {}) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:


35
36
37
38
39
40
41
42
# File 'lib/airbrake-api/configuration.rb', line 35

def configure(options={})
  @account    = options[:account] if options.has_key?(:account)
  @auth_token = options[:auth_token] if options.has_key?(:auth_token)
  @secure     = options[:secure] if options.has_key?(:secure)
  @middleware = options[:middleware] if options.has_key?(:middleware)
  yield self if block_given?
  self
end

#optionsObject


44
45
46
47
48
# File 'lib/airbrake-api/configuration.rb', line 44

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#protocolObject


54
55
56
# File 'lib/airbrake-api/configuration.rb', line 54

def protocol
  @secure ? "https" : "http"
end

#resetObject


58
59
60
61
62
63
64
65
66
# File 'lib/airbrake-api/configuration.rb', line 58

def reset
  @account    = nil
  @auth_token = nil
  @secure     = false
  @adapter    = DEFAULT_ADAPTER
  @user_agent = DEFAULT_USER_AGENT
  @connection_options = DEFAULT_CONNECTION_OPTIONS
  @middleware = DEFAULT_MIDDLEWARE
end