Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
razorsync / lib / razorsync / configuration.rb
Size: Mime:
module Razorsync
  module Configuration

    VALID_OPTIONS_KEYS = [
      :portal_name,
      :token,
      :adapter,
      :endpoint,
      :logging
    ].freeze

    #By default don't set the token
    DEFAULT_TOKEN = nil

    #By default don't set a portal name
    DEFAULT_PORTAL_NAME = nil

    # Use the default Faraday adapter.
    DEFAULT_ADAPTER = Faraday.default_adapter

    # By default request JSON data to be returned from the API.
    DEFAULT_FORMAT = :json

    attr_accessor *VALID_OPTIONS_KEYS

    # Convenience method to allow configuration options to be set in a block
    def configure
      yield self
    end

    def options
      VALID_OPTIONS_KEYS.inject({}) do |option, key|
        option.merge!(key => send(key))
      end
    end

    # When this module is extended, reset all settings.
    def self.extended(base)
      base.reset
    end

    # TODO: Update this method with the final configurations provided above.
    # Reset all configuration settings to default values.
    def reset
      self.token       = DEFAULT_TOKEN
      self.portal_name = DEFAULT_PORTAL_NAME
      self.adapter     = DEFAULT_ADAPTER
    end
  end
end