Sha256: 5934e1382682a899653cd8ff8b20af2044cb9027e5600a7a6f5944cf6570bff2
Contents?: true
Size: 1.83 KB
Versions: 4
Compression:
Stored size: 1.83 KB
Contents
require 'capgun/version' module Capgun # Defines constants and methods related to configuration module Config # The HTTP connection adapter that will be used to connect if none is set DEFAULT_ADAPTER = :net_http # The Faraday connection options if none is set DEFAULT_CONNECTION_OPTIONS = {} # API endpoint DEFAULT_ENDPOINT = 'https://api.capgun.io' # The gateway server if none is set DEFAULT_GATEWAY = nil # The auth token if none is set DEFAULT_AUTH_TOKEN = "" # The value sent in the 'User-Agent' header if none is set DEFAULT_USER_AGENT = "Capgun.io Ruby Gem #{Capgun::Version}" # The proxy server if none is set DEFAULT_PROXY = nil # An array of valid keys in the options hash when configuring a {Capgun::Client} VALID_OPTIONS_KEYS = [ :adapter, :connection_options, :endpoint, :gateway, :auth_token, :user_agent, :proxy, ] attr_accessor *VALID_OPTIONS_KEYS # When this module is extended, set all configuration options to their default values def self.extended(base) base.reset end # Convenience method to allow configuration options to be set in a block def configure yield self self end # Create a hash of options and their values def options options = {} VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)} options end # Reset all configuration options to defaults def reset self.adapter = DEFAULT_ADAPTER self.connection_options = DEFAULT_CONNECTION_OPTIONS self.endpoint = DEFAULT_ENDPOINT self.gateway = DEFAULT_GATEWAY self.auth_token = DEFAULT_AUTH_TOKEN self.user_agent = DEFAULT_USER_AGENT self.proxy = DEFAULT_PROXY self end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
capgun-0.2.0 | lib/capgun/config.rb |
capgun-0.1.2 | lib/capgun/config.rb |
capgun-0.1.1 | lib/capgun/config.rb |
capgun-0.0.3 | lib/capgun/config.rb |