Class: Rack::ECG::Check::ActiveRecordConnection
- Inherits:
-
Object
- Object
- Rack::ECG::Check::ActiveRecordConnection
- Defined in:
- lib/rack/ecg/check/active_record_connection.rb
Instance Method Summary collapse
-
#initialize ⇒ Object
constructor
Checks whether ActiveRecord is currently connected to the default database.
- #result ⇒ Object
Constructor Details
#initialize ⇒ Object
Checks whether ActiveRecord is currently connected to the default database.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/ecg/check/active_record_connection.rb', line 9 class ActiveRecordConnection def result value = "" status = Status::OK begin if defined?(ActiveRecord) value = ::ActiveRecord::Base.connection.active? status = value ? Status::OK : Status::ERROR else status = Status::ERROR value = "ActiveRecord not found" end rescue => e status = Status::ERROR value = e. end Result.new(:active_record, status, value.to_s) end CheckRegistry.instance.register(:active_record, ActiveRecordConnection) end |
Instance Method Details
#result ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rack/ecg/check/active_record_connection.rb', line 10 def result value = "" status = Status::OK begin if defined?(ActiveRecord) value = ::ActiveRecord::Base.connection.active? status = value ? Status::OK : Status::ERROR else status = Status::ERROR value = "ActiveRecord not found" end rescue => e status = Status::ERROR value = e. end Result.new(:active_record, status, value.to_s) end |