lib/bugsnag/api/configuration.rb in bugsnag-api-1.0.0 vs lib/bugsnag/api/configuration.rb in bugsnag-api-1.0.1
- old
+ new
@@ -3,11 +3,10 @@
module Bugsnag
module Api
# Configuration storage and defaults for {Client}
class Configuration
-
# Default API endpoint
DEFAULT_ENDPOINT = "https://api.bugsnag.com"
# Default User Agent header string
DEFAULT_USER_AGENT = "Bugsnag API Ruby Gem #{Bugsnag::Api::VERSION}"
@@ -20,29 +19,33 @@
builder.use Bugsnag::Api::Response::RaiseError
builder.adapter Faraday.default_adapter
end
# Configuration options
- attr_accessor :email, :password, :api_token, :endpoint, :user_agent,
- :proxy, :middleware, :connection_options, :auto_paginate,
- :per_page
+ KEYS = [:email, :password, :auth_token, :endpoint, :user_agent,
+ :proxy, :middleware, :connection_options, :auto_paginate,
+ :per_page]
+ attr_accessor *KEYS
+
# Set up configuration defaults
- def initialize
+ 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
# Load configuration from hash
def load(options = {})
- options.each {|k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=")}
+ options.each {|k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=") && !v.nil?}
end
end
end
end