module Fcoin::Configuration

Constants

DEFAULT_ADAPTER

The adapter that will be used to connect if none is set

@note The default faraday adapter is Net::HTTP

DEFAULT_API_KEY
DEFAULT_CA_FILE
DEFAULT_CA_PATH
DEFAULT_ENDPOINT

The endpoint that will be used to connect if none is set

@note There is no reason to use any other endpoint at this time

DEFAULT_FORMAT_TYPE

support ruby Hash or JSON. default is ruby Hash

DEFAULT_MIDDLEWARES
DEFAULT_PROXY
DEFAULT_SECRET_KEY
DEFAULT_SKIP_VALIDATION
DEFAULT_USER_AGENT

The user agent that will be sent to the API endpoint if none is set

DEFAULT_VALIDATION_SETTING_PATH
DEFAULT_WSS_ENDPOINT
VALID_OPTIONS_KEYS

An array of valid keys in the options hash when configuring a Fcoin::API

Public Class Methods

extended(base) click to toggle source

When this module is extended, set all configuration options to their default values and load validation setting path

# File lib/fcoin/configuration.rb, line 52
def self.extended(base)
  base.set_default
  base.load_validation_setting
end

Public Instance Methods

configure() { |self| ... } click to toggle source

Convenience method to allow configuration options to be set in block

# File lib/fcoin/configuration.rb, line 58
def configure
  yield self
  load_validation_setting
end
load_validation_setting() click to toggle source

Load a configuration file to use in the gem that config

# File lib/fcoin/configuration.rb, line 71
def load_validation_setting
  Config.load_and_set_settings([
    File.expand_path('../config/settings.yml', __FILE__),
    validation_setting_path
  ])
end
options() click to toggle source

Create a hash of options and their values

# File lib/fcoin/configuration.rb, line 64
def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end
set_default() click to toggle source

Set all configuration options to defaults

# File lib/fcoin/configuration.rb, line 79
def set_default
  self.adapter                 = DEFAULT_ADAPTER
  self.endpoint                = DEFAULT_ENDPOINT
  self.wss_endpoint            = DEFAULT_WSS_ENDPOINT
  self.user_agent              = DEFAULT_USER_AGENT
  self.api_key                 = DEFAULT_API_KEY
  self.secret_key              = DEFAULT_SECRET_KEY
  self.proxy                   = DEFAULT_PROXY
  self.ca_path                 = DEFAULT_CA_PATH
  self.ca_file                 = DEFAULT_CA_FILE
  self.middlewares             = DEFAULT_MIDDLEWARES
  self.skip_validation         = DEFAULT_SKIP_VALIDATION
  self.validation_setting_path = DEFAULT_VALIDATION_SETTING_PATH
  self.format_type             = DEFAULT_FORMAT_TYPE
end