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]
DEFAULT_ADAPTER =
:net_http
DEFAULT_USER_AGENT =
"AirbrakeAPI Ruby Gem #{AirbrakeAPI::VERSION}"
DEFAULT_CONNECTION_OPTIONS =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



19
20
21
# File 'lib/airbrake-api/configuration.rb', line 19

def self.extended(base)
  base.reset
end

Instance Method Details

#account_pathObject



37
38
39
# File 'lib/airbrake-api/configuration.rb', line 37

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

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

Yields:

  • (_self)

Yield Parameters:



23
24
25
26
27
28
29
# File 'lib/airbrake-api/configuration.rb', line 23

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)
  yield self if block_given?
  self
end

#optionsObject



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

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

#protocolObject



41
42
43
# File 'lib/airbrake-api/configuration.rb', line 41

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

#resetObject



45
46
47
48
49
50
51
52
# File 'lib/airbrake-api/configuration.rb', line 45

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