Class: TableInspector::Presenter
- Inherits:
-
Object
- Object
- TableInspector::Presenter
- Defined in:
- lib/table_inspector/presenter.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Mysql2, Postgresql, Sqlite3
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#option ⇒ Object
readonly
Returns the value of attribute option.
Class Method Summary collapse
Instance Method Summary collapse
- #extract_meta(column) ⇒ Object
- #headings ⇒ Object
-
#initialize(klass, option) ⇒ Presenter
constructor
A new instance of Presenter.
Constructor Details
#initialize(klass, option) ⇒ Presenter
Returns a new instance of Presenter.
7 8 9 10 |
# File 'lib/table_inspector/presenter.rb', line 7 def initialize(klass, option) @klass = klass @option = option end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/table_inspector/presenter.rb', line 4 def klass @klass end |
#option ⇒ Object (readonly)
Returns the value of attribute option.
4 5 6 |
# File 'lib/table_inspector/presenter.rb', line 4 def option @option end |
Class Method Details
.current ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/table_inspector/presenter.rb', line 24 def self.current adapter = ApplicationRecord.connection_db_config.adapter.camelize available_presenter = %w[Mysql2 Postgresql Sqlite3] if available_presenter.include?(adapter) "TableInspector::Presenter::#{adapter}".constantize else TableInspector::Presenter end end |
Instance Method Details
#extract_meta(column) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/table_inspector/presenter.rb', line 12 def (column) if option.colorize (column) else (column) end end |
#headings ⇒ Object
20 21 22 |
# File 'lib/table_inspector/presenter.rb', line 20 def headings ordered_keys.map(&:humanize) end |