Class: SplitIoClient::SplitFactoryRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/split_factory_registry.rb

Overview

This class manages configuration options for the split client library. If not custom configuration is required the default configuration values will be used

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSplitFactoryRegistry

Returns a new instance of SplitFactoryRegistry.



22
23
24
# File 'lib/splitclient-rb/split_factory_registry.rb', line 22

def initialize
  @api_keys_hash = Hash.new
end

Instance Attribute Details

#api_keys_hashObject

Returns the value of attribute api_keys_hash.



20
21
22
# File 'lib/splitclient-rb/split_factory_registry.rb', line 20

def api_keys_hash
  @api_keys_hash
end

Instance Method Details

#add(api_key) ⇒ Object



26
27
28
29
30
31
# File 'lib/splitclient-rb/split_factory_registry.rb', line 26

def add(api_key)
  return unless api_key

  @api_keys_hash[api_key] = 0 unless @api_keys_hash[api_key]
  @api_keys_hash[api_key] += 1
end

#number_of_factories_for(api_key) ⇒ Object



40
41
42
43
44
45
# File 'lib/splitclient-rb/split_factory_registry.rb', line 40

def number_of_factories_for(api_key)
  return 0 unless api_key
  return 0 unless @api_keys_hash.key?(api_key)

  @api_keys_hash[api_key]
end

#other_factoriesObject



47
48
49
# File 'lib/splitclient-rb/split_factory_registry.rb', line 47

def other_factories
  return !@api_keys_hash.empty?
end

#remove(api_key) ⇒ Object



33
34
35
36
37
38
# File 'lib/splitclient-rb/split_factory_registry.rb', line 33

def remove(api_key)
  return unless api_key

  @api_keys_hash[api_key] -= 1 if @api_keys_hash[api_key]
  @api_keys_hash.delete(api_key) if @api_keys_hash[api_key] == 0
end