Class: HasOffersV3::Configuration
- Inherits:
-
Object
- Object
- HasOffersV3::Configuration
- Defined in:
- lib/hasoffersv3/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ host: 'api.hasoffers.com', protocol: 'https', read_timeout: 60, base_path: '/v3', network_id: '', api_key: '', json_driver: self.default_json_driver, logger: nil, proxy_host: nil, proxy_port: nil, }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #base_uri ⇒ Object
- #http_logger ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hasoffersv3/configuration.rb', line 40 def initialize(={}) defaults = DEFAULTS.dup @options = .dup defaults.keys.each do |key| # Symbolize only keys that are needed @options[key] = @options[key.to_s] if @options.has_key?(key.to_s) end # Use default when option is not specified or nil defaults.keys.each do |key| @options[key] = defaults[key] if @options[key].nil? end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
38 39 40 |
# File 'lib/hasoffersv3/configuration.rb', line 38 def @options end |
Class Method Details
.default_json_driver ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/hasoffersv3/configuration.rb', line 4 def self.default_json_driver @_default_json_driver ||= if defined?(Oj) Oj elsif defined?(MultiJson) MultiJson else JSON end end |
Instance Method Details
#base_uri ⇒ Object
59 60 61 |
# File 'lib/hasoffersv3/configuration.rb', line 59 def base_uri "#{protocol}://#{host}#{base_path}" end |
#http_logger ⇒ Object
55 56 57 |
# File 'lib/hasoffersv3/configuration.rb', line 55 def http_logger @http_logger ||= HasOffersV3::Logger.new(logger) end |