Class: Iter::Configuration

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

Overview

Provides an object to store global configuration settings.

This class is typically not used directly, but by calling Iter.configure, which creates and updates a single instance of Models::Configuration.

An alternative way to set global configuration settings is by storing them in the following environment variables:

  • ITER_API_KEY to store the API key for the Iterable API

In case both methods are used together, Iter.configure takes precedence.

Examples:

Set the API key for the API client:

Iter.configure do |config|
  config.api_key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'
end

Set the API credentials

ENV['ITER_API_KEY'] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initialize the global configuration settings, using the values of the specified following environment variables by default.



34
35
36
37
# File 'lib/iter/configuration.rb', line 34

def initialize
  @api_key = ENV['ITER_API_KEY']
  @mock = ENV['ITER_MOCK'] == '1'
end

Instance Attribute Details

#api_keyString

Returns the API key for the API calls.

Returns:

  • (String)

    the API key for the API calls.



27
28
29
# File 'lib/iter/configuration.rb', line 27

def api_key
  @api_key
end

#mockBoolean

Returns whether to mock the HTTP calls to Iterable.

Returns:

  • (Boolean)

    whether to mock the HTTP calls to Iterable



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

def mock
  @mock
end