Class: Ohme::Configuration

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

Overview

Configuration of the Ohme API client gem.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|config| ... } ⇒ Ohme::Configuration

Initializes the configuration with default values.

Yields:

  • (config)

    Optional block to configure the client



12
13
14
15
16
17
# File 'lib/ohme/configuration.rb', line 12

def initialize
  @base_url = 'https://api-ohme.oneheart.fr/api/'
  @version = 'v1'
  @timeout = 30
  yield self if block_given?
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

#client_nameObject

Returns the value of attribute client_name.



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

def client_name
  @client_name
end

#client_secretObject

Returns the value of attribute client_secret.



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

def client_secret
  @client_secret
end

#timeoutObject

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#configure {|config| ... } ⇒ Ohme::Configuration

Configures the Ohme API client with a block.

Yields:

  • (config)

    A block to configure the client

Returns:



23
24
25
# File 'lib/ohme/configuration.rb', line 23

def configure
  yield(self) if block_given?
end

#validate!Object

Validates the configuration values.

Raises:

  • (RuntimeError)

    if required values are missing



30
31
32
33
# File 'lib/ohme/configuration.rb', line 30

def validate!
  error_on('client_name') unless @client_name
  error_on('client_secret') unless @client_secret
end