Class: Pandoru::ClientBuilders::FileBasedClientBuilder
- Inherits:
-
APIClientBuilder
- Object
- APIClientBuilder
- Pandoru::ClientBuilders::FileBasedClientBuilder
- Defined in:
- lib/pandoru/client_builder.rb
Overview
Abstract File Based Client Builder Provides base functionality for client builders that load their settings from files.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_CONFIG_FILE =
""
Constants inherited from APIClientBuilder
APIClientBuilder::DEFAULT_CLIENT_CLASS
Instance Attribute Summary collapse
-
#authenticate ⇒ Object
readonly
Returns the value of attribute authenticate.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #build ⇒ Object
- #config ⇒ Object
-
#initialize(path: nil, authenticate: true, **kwargs) ⇒ FileBasedClientBuilder
constructor
A new instance of FileBasedClientBuilder.
- #parse_config ⇒ Object
Methods inherited from APIClientBuilder
Constructor Details
#initialize(path: nil, authenticate: true, **kwargs) ⇒ FileBasedClientBuilder
Returns a new instance of FileBasedClientBuilder.
181 182 183 184 185 |
# File 'lib/pandoru/client_builder.rb', line 181 def initialize(path: nil, authenticate: true, **kwargs) super(**kwargs) @path = path @authenticate = authenticate end |
Instance Attribute Details
#authenticate ⇒ Object (readonly)
Returns the value of attribute authenticate.
179 180 181 |
# File 'lib/pandoru/client_builder.rb', line 179 def authenticate @authenticate end |
#path ⇒ Object
Returns the value of attribute path.
179 180 181 |
# File 'lib/pandoru/client_builder.rb', line 179 def path @path end |
Instance Method Details
#build ⇒ Object
200 201 202 203 204 205 206 207 208 |
# File 'lib/pandoru/client_builder.rb', line 200 def build client = build_from_settings_hash(config) if authenticate && config["USERNAME"] && config["PASSWORD"] client.login(config["USERNAME"], config["PASSWORD"]) end client end |
#config ⇒ Object
192 193 194 |
# File 'lib/pandoru/client_builder.rb', line 192 def config @config ||= parse_config end |
#parse_config ⇒ Object
196 197 198 |
# File 'lib/pandoru/client_builder.rb', line 196 def parse_config raise NotImplementedError, "Subclasses must implement parse_config" end |