Class: IsItWorking::ActiveRecordCheck
- Inherits:
-
Object
- Object
- IsItWorking::ActiveRecordCheck
- Defined in:
- lib/is_it_working/checks/active_record_check.rb
Overview
Check if the database connection used by an ActiveRecord class is up.
The ActiveRecord class that yields the connection can be specified with the :class
option. By default this will be ActiveRecord::Base.
Example
IsItWorking::Handler.new do |h|
h.check :active_record, :class => User
end
Instance Method Summary collapse
- #call(status) ⇒ Object
-
#initialize(options = {}) ⇒ ActiveRecordCheck
constructor
A new instance of ActiveRecordCheck.
Constructor Details
#initialize(options = {}) ⇒ ActiveRecordCheck
Returns a new instance of ActiveRecordCheck.
15 16 17 |
# File 'lib/is_it_working/checks/active_record_check.rb', line 15 def initialize(={}) @class = [:class] || ActiveRecord::Base end |
Instance Method Details
#call(status) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/is_it_working/checks/active_record_check.rb', line 19 def call(status) @class.connection.verify! if @class.connection.active? status.ok("#{@class}.connection is active") else status.fail("#{@class}.connection is not active") end end |