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.
216 217 218 219 |
# File 'lib/dbbrowser/connection.rb', line 216 def initialize(connection, name) @connection = connection @name = name end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
221 222 223 |
# File 'lib/dbbrowser/connection.rb', line 221 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
222 223 224 |
# File 'lib/dbbrowser/connection.rb', line 222 def name @name end |
Instance Method Details
#columns ⇒ Object
228 229 230 231 |
# File 'lib/dbbrowser/connection.rb', line 228 def columns # load columns on demand for now (cache on first lookup) @columns ||= @connection.table_columns( @name ) end |
#count ⇒ Object
224 225 226 |
# File 'lib/dbbrowser/connection.rb', line 224 def count @connection.select_value( "select count(*) from #{name}").to_i end |
#query(opts = {}) ⇒ Object
233 234 235 |
# File 'lib/dbbrowser/connection.rb', line 233 def query( opts={}) @connection.fetch_table_select_all( @name, opts ) end |