Class: Ovh::Application::Configuration
- Inherits:
-
Object
- Object
- Ovh::Application::Configuration
- Defined in:
- lib/ovh/configuration.rb
Instance Attribute Summary collapse
-
#application_key ⇒ Object
Returns the value of attribute application_key.
-
#application_secret ⇒ Object
Returns the value of attribute application_secret.
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_from_hash(hash) ⇒ Object
- #load_from_path(path) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 |
# File 'lib/ovh/configuration.rb', line 9 def initialize @endpoint = nil @application_key = nil @application_secret = nil @consumer_key = nil end |
Instance Attribute Details
#application_key ⇒ Object
Returns the value of attribute application_key.
6 7 8 |
# File 'lib/ovh/configuration.rb', line 6 def application_key @application_key end |
#application_secret ⇒ Object
Returns the value of attribute application_secret.
6 7 8 |
# File 'lib/ovh/configuration.rb', line 6 def application_secret @application_secret end |
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
6 7 8 |
# File 'lib/ovh/configuration.rb', line 6 def consumer_key @consumer_key end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
7 8 9 |
# File 'lib/ovh/configuration.rb', line 7 def endpoint @endpoint end |
Instance Method Details
#load_from_hash(hash) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ovh/configuration.rb', line 16 def load_from_hash(hash) raise InvalidConfiguration, 'Invalid configuration hash' if hash.empty? self.endpoint = hash[:endpoint] @application_key = hash[:application_key] @application_secret = hash[:application_secret] @consumer_key = hash[:consumer_key] end |
#load_from_path(path) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ovh/configuration.rb', line 25 def load_from_path(path) raise InvalidConfiguration, "no such file #{path}" unless File.exist?(path) hash = JSON.parse(File.read(path), symbolize_names: true) load_from_hash(hash) end |