Sha256: de4d465685edb95fd5e3dc2091cf82bfd5cf7d6bb41afe3d889f895a928597ac

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

require 'faraday'

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

    VALID_FORMATS = [
      :json,
      :xml].freeze

    DEFAULT_ADAPTER      = Faraday.default_adapter
    DEFAULT_ENDPOINT     = nil
    DEFAULT_PROXY        = nil
    DEFAULT_FORMAT       = nil
    DEFAULT_USER_AGENT   = "FccReboot Ruby Gem #{FccReboot::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.user_agent   = DEFAULT_USER_AGENT
      self.endpoint     = DEFAULT_ENDPOINT
      self.format       = DEFAULT_FORMAT
      self.proxy        = DEFAULT_FORMAT
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fcc_reboot-0.1 lib/fcc_reboot/configuration.rb