Class: Bugsnag::Api::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/api/configuration.rb

Overview

Configuration storage and defaults for Client

Constant Summary collapse

DEFAULT_ENDPOINT =

Default API endpoint

"https://api.bugsnag.com"
DEFAULT_USER_AGENT =

Default User Agent header string

"Bugsnag API Ruby Gem #{Bugsnag::Api::VERSION}"
RACK_BUILDER_CLASS =

In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder

defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
DEFAULT_MIDDLEWARE =

Default Faraday middleware stack

RACK_BUILDER_CLASS.new do |builder|
  builder.use Bugsnag::Api::Response::RaiseError
  builder.adapter Faraday.default_adapter
end
KEYS =

Configuration options

[:email, :password, :auth_token, :endpoint, :user_agent,
:proxy, :middleware, :connection_options, :auto_paginate,
:per_page]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Set up configuration defaults



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bugsnag/api/configuration.rb', line 32

def initialize(options = {})
  @endpoint = DEFAULT_ENDPOINT
  @user_agent = DEFAULT_USER_AGENT
  @middleware = DEFAULT_MIDDLEWARE
  @auto_paginate = false
  @connection_options = {
    :headers => {
      :user_agent => DEFAULT_USER_AGENT
    }
  }

  load(options)
end

Instance Method Details

#load(options = {}) ⇒ Object

Load configuration from hash



47
48
49
# File 'lib/bugsnag/api/configuration.rb', line 47

def load(options = {})
  options.each { |k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=") && !v.nil?}
end