Class: Appsignal::AuthCheck
- Inherits:
-
Object
- Object
- Appsignal::AuthCheck
- Defined in:
- lib/appsignal/auth_check.rb
Constant Summary collapse
- ACTION =
'auth'.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(config, logger = Appsignal.logger) ⇒ AuthCheck
constructor
A new instance of AuthCheck.
- #perform ⇒ Object
- #perform_with_result ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/appsignal/auth_check.rb', line 5 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/appsignal/auth_check.rb', line 5 def logger @logger end |
Instance Method Details
#perform ⇒ Object
12 13 14 |
# File 'lib/appsignal/auth_check.rb', line 12 def perform Appsignal::Transmitter.new(ACTION, config).transmit({}) end |
#perform_with_result ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/appsignal/auth_check.rb', line 16 def perform_with_result begin status = perform case status when '200' result = 'AppSignal has confirmed authorization!' when '401' result = 'API key not valid with AppSignal...' else result = 'Could not confirm authorization: '\ "#{status.nil? ? 'nil' : status}" end [status, result] rescue Exception => e result = 'Something went wrong while trying to '\ "authenticate with AppSignal: #{e}" [nil, result] end end |