Sha256: 3b66d9ea1d5c0a96960a003e44af9a7d7a4d6b925287df579c200ad990709661

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

require_relative "../../generated/lib/openapi_client"
require_relative "../common/closeable"
require_relative "inner_client"

class CfClient < Closeable

  # Static:
  class << self

    @@instance = CfClient.new

    def instance

      @@instance
    end
  end

  # Static - End

  def initialize(api_key = nil, config = nil, connector = nil)

    if config == nil

      @config = ConfigBuilder.new.build
    else

      @config = config
    end

    @client = InnerClient.new(api_key, config, connector)

    @config.logger.debug "Client (1): " + @client.to_s
  end

  def init(api_key = nil, config = nil, connector = nil)

    if @client == nil

      @config = config

      @client = InnerClient.new(

        api_key = api_key,
        config = config,
        connector = connector
      )

      @config.logger.debug "Client (2): " + @client.to_s
    end
  end

  def wait_for_initialization(timeout_ms: nil)
    if @client != nil
      @client.wait_for_initialization(timeout: timeout_ms)
    end
  end

  def bool_variation(identifier, target, default_value)

    @client.bool_variation(identifier, target, default_value)
  end

  def string_variation(identifier, target, default_value)

    @client.string_variation(identifier, target, default_value)
  end

  def number_variation(identifier, target, default_value)

    @client.number_variation(identifier, target, default_value)
  end

  def json_variation(identifier, target, default_value)

    @client.json_variation(identifier, target, default_value)
  end

  def destroy

    close
  end

  def close

    if @client != nil

      @client.close
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ff-ruby-server-sdk-1.4.1 lib/ff/ruby/server/sdk/api/cf_client.rb
ff-ruby-server-sdk-1.4.0 lib/ff/ruby/server/sdk/api/cf_client.rb