Sha256: b22441d8606a8bf7e1370fb7d3de5523b9377cb485da2afe279469aced8fba9b
Contents?: true
Size: 1020 Bytes
Versions: 11
Compression:
Stored size: 1020 Bytes
Contents
require 'yaml' module RestApiClient # Configuration defaults @config = { :service_key => '' } # Configure through hash def self.configure(opts = {}) opts.each { |k, v| @config[k.to_sym] = v } end # Configure the authorization_key for one client def self.configure_authorization(client_name, auth_key) @config['authorization'] ||= {} @config['authorization'][client_name] = auth_key end def self.get_auth_key(client_name) @config['authorization'] ||= {} @config['authorization'][client_name] end # Configure through yaml file def self.configure_with(path_to_yaml_file) begin config = YAML::load(IO.read(path_to_yaml_file)) configure(config) rescue Errno::ENOENT RestApiClient.logger.warn("YAML configuration file couldn't be found. Using defaults."); rescue Psych::SyntaxError RestApiClient.logger.warn('YAML configuration file contains invalid syntax. Using defaults.'); end end def self.config @config end end
Version data entries
11 entries across 11 versions & 1 rubygems