Sha256: 314437519260b9dbcea415fbdbae7436ffcc8a86486612db14cd00c412c9d43b

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require_relative "absmartly/version"
require_relative "absmartly/variant_assigner"
require_relative "absmartly/md5"
require_relative "a_b_smartly"
require_relative "a_b_smartly_config"
require_relative "client"
require_relative "client_config"
require_relative "context_config"

module Absmartly
  @@init_config = nil

  class Error < StandardError
  end

  class << self
    attr_accessor :endpoint, :api_key, :application, :environment

    def configure_client
      yield self
    end

    def create
      ABSmartly.create(sdk_config)
    end

    def create_context_config
      ContextConfig.create
    end

    def create_context(context_config)
      sdk.create_context(context_config)
    end

    private
      def client_config
        @client_config = ClientConfig.create
        @client_config.endpoint = @endpoint
        @client_config.api_key = @api_key
        @client_config.application = @application
        @client_config.environment = @environment
        @client_config
      end

      def sdk_config
        @sdk_config = ABSmartlyConfig.create
        @sdk_config.client = Client.create(client_config)
        @sdk_config
      end

      def sdk
        @sdk ||= create
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
absmartly-sdk-1.1.0 lib/absmartly.rb
absmartly-sdk-1.0.8 lib/absmartly.rb
absmartly-sdk-1.0.7 lib/absmartly.rb
absmartly-sdk-1.0.6 lib/absmartly.rb
absmartly-sdk-1.0.5 lib/absmartly.rb
absmartly-sdk-0.1.2 lib/absmartly.rb