Sha256: 94be99493fb9940accf90af0b90875ad97f3744c42fc44e39a2581f6c6f53278

Contents?: true

Size: 1.78 KB

Versions: 16

Compression:

Stored size: 1.78 KB

Contents

require 'taric/client'
require 'taric/configuration'
require 'taric/constants'
require 'taric/version'
require 'memoist'

module Taric
  class << self
    attr_accessor :configuration

    # Creates a [Taric::Client], the main interface to the LoL API. If the api_key is provided
    # in .configure!, then only the region needs to be set. If .configure! is used, but a different
    # api_key is provided, then the latter takes precedence.
    #
    # @see Taric::Client::REGION_ENDPOINT_INFO
    # @param region [Symbol] region code, also accepts [String], default is :na
    # @param api_key [String] rito API key
    # @param config [Taric::Configuration] configuration options. If not provided, then defaults will be used.
    #
    # @return [Taric::Client]
    #
    # @example
    #   # With .configure! (preferred)
    #   Taric.configure! do |config|
    #     config.api_key = 'your-rito-api-key'
    #   end
    #
    #   client = Taric.client(region: :na)
    #
    #   # With arbitrary key.
    #   client = Taric.client(region: :na, api_key: 'your-rito-key')
    def client(region: :na, api_key: nil, config: @configuration ||= Taric::Configuration.new)
      Taric::Client.new(api_key: api_key || config.api_key,
                        region: region.is_a?(String) ? region.to_sym : region,
                        config: config)
    end

    # Sets global configuration. Should only be called once in a process (e.g. Rails initializer)
    #
    # @see Taric::Configuration
    #
    # @example
    #   Taric.configure! do |config|
    #     config.api_key = 'your_api_key'
    #   end
    def configure!
      reset!
      yield(configuration)
    end

    # Resets global configuration.
    # @see Taric::Configuration
    def reset!
      @configuration = Taric::Configuration.new
    end


  end

end


Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
taric-2.0.0.pre.alpha.1 lib/taric.rb
taric-2.0.0.pre.alpha lib/taric.rb
taric-1.0.0 lib/taric.rb
taric-1.0.0.pre.beta.0 lib/taric.rb
taric-1.0.0.pre.alpha.8 lib/taric.rb
taric-1.0.0.pre.alpha.6 lib/taric.rb
taric-1.0.0.pre.alpha.4 lib/taric.rb
taric-1.0.0.pre.alpha.3 lib/taric.rb
taric-1.0.0.pre.alpha.2 lib/taric.rb
taric-1.0.0.pre.alpha.1 lib/taric.rb
taric-1.0.0.pre.alpha lib/taric.rb
taric-0.5.1 lib/taric.rb
taric-0.5.0 lib/taric.rb
taric-0.4.0 lib/taric.rb
taric-0.3.4 lib/taric.rb
taric-0.3.3 lib/taric.rb