Class: Rack::ECG::Check::SequelConnection
- Inherits:
-
Object
- Object
- Rack::ECG::Check::SequelConnection
- Defined in:
- lib/rack/ecg/check/sequel_connection.rb
Instance Attribute Summary collapse
-
#connection_parameters ⇒ Object
readonly
Returns the value of attribute connection_parameters.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(parameters = {}) ⇒ SequelConnection
constructor
Checks whether Sequel can connect to the database identified by the
connection
option. - #result ⇒ Object
- #result_key ⇒ Object
Constructor Details
#initialize(parameters = {}) ⇒ SequelConnection
Checks whether Sequel can connect to the database identified by the connection
option.
14 15 16 17 |
# File 'lib/rack/ecg/check/sequel_connection.rb', line 14 def initialize(parameters = {}) @connection_parameters = parameters[:connection] @name = parameters[:name] end |
Instance Attribute Details
#connection_parameters ⇒ Object (readonly)
Returns the value of attribute connection_parameters.
7 8 9 |
# File 'lib/rack/ecg/check/sequel_connection.rb', line 7 def connection_parameters @connection_parameters end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rack/ecg/check/sequel_connection.rb', line 7 def name @name end |
Instance Method Details
#result ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rack/ecg/check/sequel_connection.rb', line 19 def result value = "" status = Status::OK begin if connection_parameters.nil? status = Status::ERROR value = "Sequel Connection parameters not found" elsif defined?(::Sequel) ::Sequel.connect(connection_parameters) do |db| value = db.test_connection status = Status::OK end else status = Status::ERROR value = "Sequel not found" end rescue => e status = Status::ERROR value = e. end Result.new(result_key.to_sym, status, value.to_s) end |
#result_key ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rack/ecg/check/sequel_connection.rb', line 43 def result_key if name "sequel #{name.downcase}".gsub(/\W+/, "_") else "sequel" end end |