Sha256: 3708dd108265575b15466ac659afa895d93d31cb9f941da1eb88e97de9fb0e04

Contents?: true

Size: 1.09 KB

Versions: 158

Compression:

Stored size: 1.09 KB

Contents

require 'logger'
require 'socket'

module SplitIoClient

  class << self
      attr_accessor :split_factory_registry
  end

  def self.load_factory_registry
    self.split_factory_registry ||= SplitFactoryRegistry.new
  end

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

    attr_accessor :api_keys_hash

    def initialize
      @api_keys_hash = Hash.new
    end

    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

    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

    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

    def other_factories
      return !@api_keys_hash.empty?
    end
  end
end

Version data entries

158 entries across 158 versions & 1 rubygems

Version Path
splitclient-rb-7.0.1.pre.rc6-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc6 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc5-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc5 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc4-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc4 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc3-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc3 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc1-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.1.pre.rc1 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0.pre.rc3-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0.pre.rc3 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0.pre.rc2-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0.pre.rc2 lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0.pre.rc1-java lib/splitclient-rb/split_factory_registry.rb
splitclient-rb-7.0.0.pre.rc1 lib/splitclient-rb/split_factory_registry.rb