Class: Ovh::Application::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ovh/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_keyObject

Returns the value of attribute application_key.



6
7
8
# File 'lib/ovh/configuration.rb', line 6

def application_key
  @application_key
end

#application_secretObject

Returns the value of attribute application_secret.



6
7
8
# File 'lib/ovh/configuration.rb', line 6

def application_secret
  @application_secret
end

#consumer_keyObject

Returns the value of attribute consumer_key.



6
7
8
# File 'lib/ovh/configuration.rb', line 6

def consumer_key
  @consumer_key
end

#endpointObject

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