Class: QuizApiClient::Config
- Inherits:
-
Object
- Object
- QuizApiClient::Config
- 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
- DEFAULT_USER_AGENT =
"QuizApiClient/#{QuizApiClient::VERSION} (Ruby)".freeze
- ERROR_HANDLERS =
%i[sentry_raven sentry_rails].freeze
- METRICS_HANDLERS =
%i[inststatsd].freeze
Instance Attribute Summary collapse
- #allowable_response_codes ⇒ Object
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#consumer_request_id ⇒ Object
Returns the value of attribute consumer_request_id.
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#host ⇒ Object
Returns the value of attribute host.
-
#metrics_handler ⇒ Object
readonly
Returns the value of attribute metrics_handler.
-
#metrics_namespace ⇒ Object
readonly
Returns the value of attribute metrics_namespace.
- #protocol ⇒ Object
-
#shared_secret ⇒ Object
Returns the value of attribute shared_secret.
- #user_agent ⇒ Object
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
- #setup_metrics(handler, namespace) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
17 18 19 |
# File 'lib/quiz_api_client/config.rb', line 17 def initialize yield(self) if block_given? end |
Instance Attribute Details
#allowable_response_codes ⇒ Object
39 40 41 |
# File 'lib/quiz_api_client/config.rb', line 39 def allowable_response_codes @allowable_response_codes || DEFAULT_ALLOWABLE_RESPONSE_CODES end |
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
15 16 17 |
# File 'lib/quiz_api_client/config.rb', line 15 def consumer_key @consumer_key end |
#consumer_request_id ⇒ Object
Returns the value of attribute consumer_request_id.
15 16 17 |
# File 'lib/quiz_api_client/config.rb', line 15 def consumer_request_id @consumer_request_id end |
#error_handler ⇒ Object
Returns the value of attribute error_handler.
13 14 15 |
# File 'lib/quiz_api_client/config.rb', line 13 def error_handler @error_handler end |
#host ⇒ Object
Returns the value of attribute host.
15 16 17 |
# File 'lib/quiz_api_client/config.rb', line 15 def host @host end |
#metrics_handler ⇒ Object (readonly)
Returns the value of attribute metrics_handler.
13 14 15 |
# File 'lib/quiz_api_client/config.rb', line 13 def metrics_handler @metrics_handler end |
#metrics_namespace ⇒ Object (readonly)
Returns the value of attribute metrics_namespace.
13 14 15 |
# File 'lib/quiz_api_client/config.rb', line 13 def metrics_namespace @metrics_namespace end |
#protocol ⇒ Object
21 22 23 |
# File 'lib/quiz_api_client/config.rb', line 21 def protocol @protocol || DEFAULT_PROTOCOL end |
#shared_secret ⇒ Object
Returns the value of attribute shared_secret.
15 16 17 |
# File 'lib/quiz_api_client/config.rb', line 15 def shared_secret @shared_secret end |
#user_agent ⇒ Object
43 44 45 |
# File 'lib/quiz_api_client/config.rb', line 43 def user_agent @user_agent || DEFAULT_USER_AGENT end |
Instance Method Details
#setup_metrics(handler, namespace) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/quiz_api_client/config.rb', line 31 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 |