Sha256: 9a95b9efd478c7b98cd843c8836740c9bd87c50e0edd985479b1b7a561911ccd

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require 'simple_segment/logging'

module SimpleSegment
  class Configuration
    include SimpleSegment::Utils
    include SimpleSegment::Logging

    DEFAULT_HOST = 'api.segment.io'

    attr_reader :write_key, :on_error, :stub, :logger, :http_options, :host

    def initialize(settings = {})
      symbolized_settings = symbolize_keys(settings)
      @write_key = symbolized_settings[:write_key]
      @on_error = symbolized_settings[:on_error] || proc {}
      @stub = symbolized_settings[:stub]
      @logger = default_logger(symbolized_settings[:logger])
      @http_options = { use_ssl: true }
                      .merge(symbolized_settings[:http_options] || {})
      @host = symbolized_settings[:host] || DEFAULT_HOST
      raise ArgumentError, 'Missing required option :write_key' \
        unless @write_key
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_segment-1.5.0 lib/simple_segment/configuration.rb
simple_segment-1.4.0 lib/simple_segment/configuration.rb