Class: DbBrowser::ConnectionMan::Table
- Inherits:
-
Object
- Object
- DbBrowser::ConnectionMan::Table
- Defined in:
- lib/dbbrowser/connection.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #columns ⇒ Object
- #count ⇒ Object
-
#initialize(connection, name) ⇒ Table
constructor
A new instance of Table.
- #query(opts = {}) ⇒ Object
Constructor Details
#initialize(connection, name) ⇒ Table
Returns a new instance of Table.
189 190 191 192 |
# File 'lib/dbbrowser/connection.rb', line 189 def initialize(connection, name) @connection = connection @name = name end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
194 195 196 |
# File 'lib/dbbrowser/connection.rb', line 194 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
195 196 197 |
# File 'lib/dbbrowser/connection.rb', line 195 def name @name end |
Instance Method Details
#columns ⇒ Object
201 202 203 204 |
# File 'lib/dbbrowser/connection.rb', line 201 def columns # load columns on demand for now (cache on first lookup) @columns ||= @connection.table_columns( @name ) end |
#count ⇒ Object
197 198 199 |
# File 'lib/dbbrowser/connection.rb', line 197 def count @connection.select_value( "select count(*) from #{name}").to_i end |
#query(opts = {}) ⇒ Object
206 207 208 |
# File 'lib/dbbrowser/connection.rb', line 206 def query( opts={}) @connection.fetch_table_select_all( @name, opts ) end |