Sha256: 526e8a7ec74103ce38ff559127b4f52c139b4f8d3c1edf77be24d9b31b17a6fa

Contents?: true

Size: 952 Bytes

Versions: 7

Compression:

Stored size: 952 Bytes

Contents

require 'faraday'
require 'connexionz/version'

module Connexionz
  module Configuration
    VALID_OPTIONS_KEYS = [
      :adapter,
      :endpoint,
      :format,
      :proxy,
      :user_agent].freeze

    VALID_FORMATS = [
      :xml].freeze

    DEFAULT_ADAPTER      = :patron #Faraday.default_adapter
    DEFAULT_ENDPOINT     = nil
    DEFAULT_FORMAT       = :xml
    DEFAULT_PROXY        = nil
    DEFAULT_USER_AGENT   = "Connexionz Ruby Gem #{Connexionz::VERSION}".freeze

    attr_accessor *VALID_OPTIONS_KEYS

    def self.extended(base)
      base.reset
    end

    def configure
      yield self
    end

    def options
      VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
    end

    def reset
      self.adapter      = DEFAULT_ADAPTER
      self.endpoint     = DEFAULT_ENDPOINT
      self.format       = DEFAULT_FORMAT
      self.proxy        = DEFAULT_PROXY
      self.user_agent   = DEFAULT_USER_AGENT
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
connexionz-1.0.4 lib/connexionz/configuration.rb
connexionz-1.0.3 lib/connexionz/configuration.rb
connexionz-1.0.2 lib/connexionz/configuration.rb
connexionz-1.0.1 lib/connexionz/configuration.rb
connexionz-1.0.0 lib/connexionz/configuration.rb
connexionz-0.0.2 lib/connexionz/configuration.rb
connexionz-0.0.1 lib/connexionz/configuration.rb