Class: QuizApiClient::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/quiz_api_client/config.rb

Defined Under Namespace

Classes: InvalidErrorHandler, InvalidMetricsHandler, InvalidMetricsNamespace

Constant Summary collapse

DEFAULT_ALLOWABLE_RESPONSE_CODES =
[401, 422].freeze
DEFAULT_PROTOCOL =
'https'.freeze
ERROR_HANDLERS =
%i[sentry_raven].freeze
METRICS_HANDLERS =
%i[inststatsd].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



16
17
18
# File 'lib/quiz_api_client/config.rb', line 16

def initialize
  yield(self) if block_given?
end

Instance Attribute Details

#allowable_response_codesObject



38
39
40
# File 'lib/quiz_api_client/config.rb', line 38

def allowable_response_codes
  @allowable_response_codes || DEFAULT_ALLOWABLE_RESPONSE_CODES
end

#consumer_keyObject

Returns the value of attribute consumer_key.



14
15
16
# File 'lib/quiz_api_client/config.rb', line 14

def consumer_key
  @consumer_key
end

#consumer_request_idObject

Returns the value of attribute consumer_request_id.



14
15
16
# File 'lib/quiz_api_client/config.rb', line 14

def consumer_request_id
  @consumer_request_id
end

#error_handlerObject

Returns the value of attribute error_handler.



12
13
14
# File 'lib/quiz_api_client/config.rb', line 12

def error_handler
  @error_handler
end

#hostObject

Returns the value of attribute host.



14
15
16
# File 'lib/quiz_api_client/config.rb', line 14

def host
  @host
end

#metrics_handlerObject (readonly)

Returns the value of attribute metrics_handler.



12
13
14
# File 'lib/quiz_api_client/config.rb', line 12

def metrics_handler
  @metrics_handler
end

#metrics_namespaceObject (readonly)

Returns the value of attribute metrics_namespace.



12
13
14
# File 'lib/quiz_api_client/config.rb', line 12

def metrics_namespace
  @metrics_namespace
end

#protocolObject



20
21
22
# File 'lib/quiz_api_client/config.rb', line 20

def protocol
  @protocol || DEFAULT_PROTOCOL
end

#shared_secretObject

Returns the value of attribute shared_secret.



14
15
16
# File 'lib/quiz_api_client/config.rb', line 14

def shared_secret
  @shared_secret
end

Instance Method Details

#setup_metrics(handler, namespace) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/quiz_api_client/config.rb', line 30

def setup_metrics(handler, namespace)
  validate_metrics_handler!(handler)
  validate_metrics_namespace!(namespace)

  @metrics_handler = handler.to_sym
  @metrics_namespace = namespace.to_s.strip
end