Class: Increase::Configuration
- Inherits:
-
Object
- Object
- Increase::Configuration
- Defined in:
- lib/increase/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#raise_api_errors ⇒ Object
Returns the value of attribute raise_api_errors.
Instance Method Summary collapse
- #configure(config = nil) ⇒ Object
-
#initialize(config = nil) ⇒ Configuration
constructor
TODO: support Faraday config.
- #reset ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Configuration
TODO: support Faraday config
10 11 12 13 |
# File 'lib/increase/configuration.rb', line 10 def initialize(config = nil) reset configure(config) if config end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/increase/configuration.rb', line 6 def api_key @api_key end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/increase/configuration.rb', line 5 def base_url @base_url end |
#raise_api_errors ⇒ Object
Returns the value of attribute raise_api_errors.
7 8 9 |
# File 'lib/increase/configuration.rb', line 7 def raise_api_errors @raise_api_errors end |
Instance Method Details
#configure(config = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/increase/configuration.rb', line 21 def configure(config = nil) if config.is_a?(Hash) config.each do |key, value| unless respond_to?("#{key}=") raise ArgumentError, "Invalid configuration: #{key}" end public_send("#{key}=", value) end end if block_given? yield self end self end |
#reset ⇒ Object
15 16 17 18 19 |
# File 'lib/increase/configuration.rb', line 15 def reset @base_url = ENV["INCREASE_BASE_URL"] || Increase::PRODUCTION_URL @api_key = ENV["INCREASE_API_KEY"] @raise_api_errors = true end |