Class: Nquery::SchemaExplorer
- Inherits:
-
Object
- Object
- Nquery::SchemaExplorer
- Defined in:
- lib/nquery/schema_explorer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data_source) ⇒ SchemaExplorer
constructor
A new instance of SchemaExplorer.
- #tables ⇒ Object
Constructor Details
#initialize(data_source) ⇒ SchemaExplorer
Returns a new instance of SchemaExplorer.
9 10 11 |
# File 'lib/nquery/schema_explorer.rb', line 9 def initialize(data_source) @data_source = data_source end |
Class Method Details
.tables_for(data_source) ⇒ Object
5 6 7 |
# File 'lib/nquery/schema_explorer.rb', line 5 def self.tables_for(data_source) new(data_source).tables end |
Instance Method Details
#tables ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nquery/schema_explorer.rb', line 13 def tables return [] unless @data_source adapter = DataSources::Adapter.for(@data_source) adapter.tables.map do |table| { name: table, columns: adapter.columns(table) } end rescue StandardError => e Rails.logger.error("[Nquery::SchemaExplorer] #{e.class}: #{e.}\n#{e.backtrace&.first(8)&.join("\n")}") [] end |