Sha256: 2bb4bc3eaf37dc070fccfa42aaf92d1ace3c5e0a0662d79d3ccc796abd2fd6e0
Contents?: true
Size: 711 Bytes
Versions: 13
Compression:
Stored size: 711 Bytes
Contents
# frozen_string_literal: true module ErpIntegration # The `ApiKeysPool` class is a simple # class that holds a list of API keys # and rotates between them. class ApiKeysPool attr_reader :api_keys def initialize @api_keys = [] @current_key_index = 0 end # Allows setting a list of API keys for the pool. def api_keys=(keys) @api_keys = Array(keys) end # Returns the current API key. # @return [String] The current API key. def current_key @api_keys[@current_key_index] end # Rotates the API key to the next one in the list. def rotate_key! @current_key_index = (@current_key_index + 1) % @api_keys.size end end end
Version data entries
13 entries across 13 versions & 1 rubygems