Class: Softlayer::Config
- Inherits:
-
Object
- Object
- Softlayer::Config
- Defined in:
- lib/softlayer/config.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#impersonate_token ⇒ Object
Returns the value of attribute impersonate_token.
-
#impersonate_user ⇒ Object
Returns the value of attribute impersonate_user.
-
#mock ⇒ Object
Returns the value of attribute mock.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#check! ⇒ Object
Check the configuration.
-
#initialize(params = {}) ⇒ Config
constructor
A new instance of Config.
- #mock? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 18 19 |
# File 'lib/softlayer/config.rb', line 13 def initialize(params = {}) @username = params[:username] if params[:username] @api_key = params[:api_key] if params[:api_key] @open_timeout = 5 @read_timeout = 5 @mock = false end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/softlayer/config.rb', line 4 def api_key @api_key end |
#impersonate_token ⇒ Object
Returns the value of attribute impersonate_token.
9 10 11 |
# File 'lib/softlayer/config.rb', line 9 def impersonate_token @impersonate_token end |
#impersonate_user ⇒ Object
Returns the value of attribute impersonate_user.
8 9 10 |
# File 'lib/softlayer/config.rb', line 8 def impersonate_user @impersonate_user end |
#mock ⇒ Object
Returns the value of attribute mock.
11 12 13 |
# File 'lib/softlayer/config.rb', line 11 def mock @mock end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
5 6 7 |
# File 'lib/softlayer/config.rb', line 5 def open_timeout @open_timeout end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
6 7 8 |
# File 'lib/softlayer/config.rb', line 6 def read_timeout @read_timeout end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/softlayer/config.rb', line 3 def username @username end |
Instance Method Details
#check! ⇒ Object
Check the configuration.
Will raise a Softlayer::Errors::MissingConfigOption if any of the API login ID or the API key are missing.
24 25 26 27 |
# File 'lib/softlayer/config.rb', line 24 def check! fail Softlayer::Errors::MissingConfigOption.new('username') unless username && username.strip.length > 0 fail Softlayer::Errors::MissingConfigOption.new('api_key') unless api_key && api_key.strip.length > 0 end |