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.
195 196 197 198 |
# File 'lib/dbbrowser/connection.rb', line 195 def initialize(connection, name) @connection = connection @name = name end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
200 201 202 |
# File 'lib/dbbrowser/connection.rb', line 200 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
201 202 203 |
# File 'lib/dbbrowser/connection.rb', line 201 def name @name end |
Instance Method Details
#columns ⇒ Object
207 208 209 210 |
# File 'lib/dbbrowser/connection.rb', line 207 def columns # load columns on demand for now (cache on first lookup) @columns ||= @connection.table_columns( @name ) end |
#count ⇒ Object
203 204 205 |
# File 'lib/dbbrowser/connection.rb', line 203 def count @connection.select_value( "select count(*) from #{name}").to_i end |
#query(opts = {}) ⇒ Object
212 213 214 |
# File 'lib/dbbrowser/connection.rb', line 212 def query( opts={}) @connection.fetch_table_select_all( @name, opts ) end |