Sha256: e414ae214589a0fd46d9f39b76332ec70af5a6af47f2ef362134337cdb705637

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require "bugsnag/api/version"
require "bugsnag/api/response/raise_error"

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}"

      # In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder
      RACK_BUILDER_CLASS = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder

      # Default Faraday middleware stack
      DEFAULT_MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder|
        builder.use Bugsnag::Api::Response::RaiseError
        builder.adapter Faraday.default_adapter
      end

      # Configuration options
      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(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}=") && !v.nil?}
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bugsnag-api-2.0.1 lib/bugsnag/api/configuration.rb
bugsnag-api-2.0.0 lib/bugsnag/api/configuration.rb
bugsnag-api-1.0.3 lib/bugsnag/api/configuration.rb
bugsnag-api-1.0.2 lib/bugsnag/api/configuration.rb