Class: ErpIntegration::ApiKeysPool
- Inherits:
-
Object
- Object
- ErpIntegration::ApiKeysPool
- 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
-
#api_keys ⇒ Object
Returns the value of attribute api_keys.
Instance Method Summary collapse
-
#current_key ⇒ String
Returns the current API key.
-
#initialize ⇒ ApiKeysPool
constructor
A new instance of ApiKeysPool.
-
#rotate_key! ⇒ Object
Rotates the API key to the next one in the list.
Constructor Details
#initialize ⇒ ApiKeysPool
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_keys ⇒ Object
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_key ⇒ String
Returns 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 |