Class: ErpIntegration::ApiKeysPool

Inherits:
Object
  • Object
show all
Defined in:
lib/erp_integration/api_keys_pool.rb

Overview

The ‘ApiKeysPool` class is a simple class that holds a list of API keys and rotates between them.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApiKeysPool

Returns a new instance of ApiKeysPool.



10
11
12
13
# File 'lib/erp_integration/api_keys_pool.rb', line 10

def initialize
  @api_keys = []
  @current_key_index = 0
end

Instance Attribute Details

#api_keysObject

Returns the value of attribute api_keys.



8
9
10
# File 'lib/erp_integration/api_keys_pool.rb', line 8

def api_keys
  @api_keys
end

Instance Method Details

#current_keyString

Returns the current API key.

Returns:

  • (String)

    The current API key.



22
23
24
# File 'lib/erp_integration/api_keys_pool.rb', line 22

def current_key
  @api_keys[@current_key_index]
end

#rotate_key!Object

Rotates the API key to the next one in the list.



27
28
29
# File 'lib/erp_integration/api_keys_pool.rb', line 27

def rotate_key!
  @current_key_index = (@current_key_index + 1) % @api_keys.size
end