Class: Bloomy::Configuration
- Inherits:
-
Object
- Object
- Bloomy::Configuration
- Defined in:
- lib/bloomy/configuration.rb
Overview
The Configuration class is responsible for managing the authentication
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#configure_api_key(username, password, store_key: false) ⇒ void
Configures the API key using the provided username and password.
-
#initialize(api_key = nil) ⇒ Configuration
constructor
Initializes a new Configuration instance.
Constructor Details
#initialize(api_key = nil) ⇒ Configuration
Initializes a new Configuration instance
17 18 19 |
# File 'lib/bloomy/configuration.rb', line 17 def initialize(api_key = nil) @api_key = api_key || ENV["BG_API_KEY"] || load_api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/bloomy/configuration.rb', line 10 def api_key @api_key end |
Instance Method Details
#configure_api_key(username, password, store_key: false) ⇒ void
Note:
This method only fetches and stores the API key if it is currently nil. It saves the key under ‘~/.bloomy/config.yaml’ if ‘store_key: true’ is passed.
This method returns an undefined value.
Configures the API key using the provided username and password
33 34 35 36 |
# File 'lib/bloomy/configuration.rb', line 33 def configure_api_key(username, password, store_key: false) @api_key = fetch_api_key(username, password) store_api_key if store_key end |