Class: Athar::Dashboard::ConnectionInfo
- Inherits:
-
Object
- Object
- Athar::Dashboard::ConnectionInfo
- Defined in:
- lib/athar/dashboard/connection_info.rb
Overview
Database name + Postgres major version, rendered in the topbar.
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(database:, version:) ⇒ ConnectionInfo
constructor
A new instance of ConnectionInfo.
Constructor Details
#initialize(database:, version:) ⇒ ConnectionInfo
Returns a new instance of ConnectionInfo.
17 18 19 20 21 22 |
# File 'lib/athar/dashboard/connection_info.rb', line 17 def initialize(database:, version:) @database = database @version = version freeze end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
7 8 9 |
# File 'lib/athar/dashboard/connection_info.rb', line 7 def database @database end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/athar/dashboard/connection_info.rb', line 7 def version @version end |
Class Method Details
.fetch(connection: ActiveRecord::Base.connection, db_config: ActiveRecord::Base.connection_db_config) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/athar/dashboard/connection_info.rb', line 9 def self.fetch( connection: ActiveRecord::Base.connection, db_config: ActiveRecord::Base.connection_db_config ) version_num = connection.select_value("SHOW server_version_num").to_i new(database: db_config.database.to_s, version: "pg#{version_num / 10_000}") end |