Parent

Files

Class Index [+]

Quicksearch

ActiveRecord::ConnectionAdapters::SchemaCache

Attributes

columns[R]
columns_hash[R]
primary_keys[R]
tables[R]
connection[R]

Public Class Methods

new(conn) click to toggle source
    # File lib/active_record/connection_adapters/schema_cache.rb, line 7
 7:       def initialize(conn)
 8:         @connection = conn
 9:         @tables     = {}
10: 
11:         @columns = Hash.new do |h, table_name|
12:           h[table_name] = conn.columns(table_name, "#{table_name} Columns")
13:         end
14: 
15:         @columns_hash = Hash.new do |h, table_name|
16:           h[table_name] = Hash[columns[table_name].map { |col|
17:             [col.name, col]
18:           }]
19:         end
20: 
21:         @primary_keys = Hash.new do |h, table_name|
22:           h[table_name] = table_exists?(table_name) ? conn.primary_key(table_name) : nil
23:         end
24:       end

Public Instance Methods

clear!() click to toggle source

Clears out internal caches

    # File lib/active_record/connection_adapters/schema_cache.rb, line 34
34:       def clear!
35:         @columns.clear
36:         @columns_hash.clear
37:         @primary_keys.clear
38:         @tables.clear
39:       end
clear_table_cache!(table_name) click to toggle source

Clear out internal caches for table with table_name.

    # File lib/active_record/connection_adapters/schema_cache.rb, line 42
42:       def clear_table_cache!(table_name)
43:         @columns.delete table_name
44:         @columns_hash.delete table_name
45:         @primary_keys.delete table_name
46:         @tables.delete table_name
47:       end
table_exists?(name) click to toggle source

A cached lookup for table existence.

    # File lib/active_record/connection_adapters/schema_cache.rb, line 27
27:       def table_exists?(name)
28:         return @tables[name] if @tables.key? name
29: 
30:         @tables[name] = connection.table_exists?(name)
31:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.