Class: Taric::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/taric/configuration.rb

Constant Summary collapse

DEFAULT_REQUESTOR =
-> (connection, method, url, body, headers) {
  connection.send(method, url, body, headers)
}.curry
DEFAULT_RESPONSE_HANDLER =
-> response {
  response
}
PARALLEL_REQUESTOR =
-> connection, operations {
  operations.map{|operation| connection.send(operation[:method], operation[:url], operation[:body], operation[:headers])}
}.curry
PARALLEL_RESPONSE_HANDLER =
-> responses {
  responses.map{|response| response}
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/taric/configuration.rb', line 21

def initialize(options = {})
  @api_key = options.fetch(:api_key, ENV.fetch('RIOT_API_KEY'.freeze, nil))
  @format = options.fetch(:format, :json)
  @user_agent = options.fetch(:user_agent, 'Taric Gem')
  @adapter = options.fetch(:adapter, Faraday.default_adapter)
  @region = options.fetch(:region, ENV.fetch('RIOT_API_REGION'.freeze, 'na').to_sym)
  @connection_opts = options.fetch(:connection_opts, {})
  @requestor = options.fetch(:requestor, DEFAULT_REQUESTOR)
  @response_handler = options.fetch(:response_handler, DEFAULT_RESPONSE_HANDLER)
  @parallel_requestor = options.fetch(:parallel_requestor, PARALLEL_REQUESTOR)
  @parallel_response_handler = options.fetch(:parallel_response_handler, PARALLEL_RESPONSE_HANDLER)
  @raw = options.fetch(:raw, false)
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def adapter
  @adapter
end

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def api_key
  @api_key
end

#connection_optsObject

Returns the value of attribute connection_opts.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def connection_opts
  @connection_opts
end

#formatObject

Returns the value of attribute format.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def format
  @format
end

#parallel_requestorObject

Returns the value of attribute parallel_requestor.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def parallel_requestor
  @parallel_requestor
end

#parallel_response_handlerObject

Returns the value of attribute parallel_response_handler.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def parallel_response_handler
  @parallel_response_handler
end

#rawObject

Returns the value of attribute raw.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def raw
  @raw
end

#regionObject

Returns the value of attribute region.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def region
  @region
end

#requestorObject

Returns the value of attribute requestor.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def requestor
  @requestor
end

#response_handlerObject

Returns the value of attribute response_handler.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def response_handler
  @response_handler
end

#user_agentObject

Returns the value of attribute user_agent.



3
4
5
# File 'lib/taric/configuration.rb', line 3

def user_agent
  @user_agent
end