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.



195
196
197
198
# File 'lib/dbbrowser/connection.rb', line 195

def initialize(connection, name)
  @connection = connection
  @name       = name
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



200
201
202
# File 'lib/dbbrowser/connection.rb', line 200

def connection
  @connection
end

#nameObject (readonly)

Returns the value of attribute name.



201
202
203
# File 'lib/dbbrowser/connection.rb', line 201

def name
  @name
end

Instance Method Details

#columnsObject



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

#countObject



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