Class: Puree::API::Configuration
- Inherits:
-
Object
- Object
- Puree::API::Configuration
- Defined in:
- lib/puree/api/configuration.rb
Overview
Configuration for Pure host and credentials.
Instance Attribute Summary collapse
- #password ⇒ String? readonly
- #url ⇒ String readonly
- #username ⇒ String? readonly
Instance Method Summary collapse
-
#basic_auth(username:, password:) ⇒ Object
Provide Basic Authentication credentials if required.
- #basic_auth? ⇒ Boolean
-
#initialize(url:) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(url:) ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 |
# File 'lib/puree/api/configuration.rb', line 18 def initialize(url:) raise 'Missing URL in configuration' if !url @url = url end |
Instance Attribute Details
#password ⇒ String? (readonly)
16 17 18 |
# File 'lib/puree/api/configuration.rb', line 16 def password @password end |
#url ⇒ String (readonly)
10 11 12 |
# File 'lib/puree/api/configuration.rb', line 10 def url @url end |
#username ⇒ String? (readonly)
13 14 15 |
# File 'lib/puree/api/configuration.rb', line 13 def username @username end |
Instance Method Details
#basic_auth(username:, password:) ⇒ Object
Provide Basic Authentication credentials if required
27 28 29 30 31 32 33 |
# File 'lib/puree/api/configuration.rb', line 27 def basic_auth(username:, password:) @username = username @password = password msg = 'Credentials incomplete in configuration' raise msg if username && !password raise msg if password && !username end |
#basic_auth? ⇒ Boolean
35 36 37 |
# File 'lib/puree/api/configuration.rb', line 35 def basic_auth? @username && @password end |