Class: TableSaw::Queries::TableColumns
- Inherits:
-
Object
- Object
- TableSaw::Queries::TableColumns
- Defined in:
- lib/table_saw/queries/table_columns.rb
Constant Summary collapse
- QUERY =
<<~SQL select attname as colname from pg_catalog.pg_attribute where attrelid = $1::regclass and attnum > 0 and attisdropped = false order by attnum SQL
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(table) ⇒ TableColumns
constructor
A new instance of TableColumns.
Constructor Details
#initialize(table) ⇒ TableColumns
Returns a new instance of TableColumns.
18 19 20 |
# File 'lib/table_saw/queries/table_columns.rb', line 18 def initialize(table) @table = table end |
Instance Attribute Details
#table ⇒ Object (readonly)
Returns the value of attribute table.
16 17 18 |
# File 'lib/table_saw/queries/table_columns.rb', line 16 def table @table end |
Instance Method Details
#call ⇒ Object
22 23 24 |
# File 'lib/table_saw/queries/table_columns.rb', line 22 def call TableSaw::Connection.with { |conn| conn.exec_params(QUERY, [table]) }.map { |r| r['colname'] } end |