Class: GoFlippy::Client
- Inherits:
-
Object
- Object
- GoFlippy::Client
- Includes:
- Logger
- Defined in:
- lib/goflippy/client.rb
Constant Summary
Constants included from Logger
Instance Method Summary collapse
- #enabled?(key, uid, default) ⇒ Boolean
-
#initialize(api_key, opts = {}) ⇒ Client
constructor
A new instance of Client.
- #start ⇒ Object
Methods included from Logger
debug, error, fatal, info, logger, logger=, unknown, warn
Constructor Details
#initialize(api_key, opts = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 |
# File 'lib/goflippy/client.rb', line 5 def initialize(api_key, opts = {}) @api_key = api_key @config = opts&.empty? ? Config.default : Config.new(opts) @store = MemoryStore.new @http_client = HttpClient.new(@api_key, @config) @poller = Poller.new(@config.polling_interval, @http_client, @store) end |
Instance Method Details
#enabled?(key, uid, default) ⇒ Boolean
18 19 20 21 |
# File 'lib/goflippy/client.rb', line 18 def enabled?(key, uid, default) uids = @store.find(key) uids&.dig(uid.to_sym) || default end |
#start ⇒ Object
13 14 15 16 |
# File 'lib/goflippy/client.rb', line 13 def start Logger.info('Start GoFlippy client') @poller.start end |