Class: DbBrowser::ConnectionMan::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/dbbrowser/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (readonly)

Returns the value of attribute connection.



221
222
223
# File 'lib/dbbrowser/connection.rb', line 221

def connection
  @connection
end

#nameObject (readonly)

Returns the value of attribute name.



222
223
224
# File 'lib/dbbrowser/connection.rb', line 222

def name
  @name
end

Instance Method Details

#columnsObject



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

#countObject



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