Class: ActiveRecord::ConnectionAdapters::Sqlserver::SchemaCache
- Inherits:
-
ActiveRecord::ConnectionAdapters::SchemaCache
- Object
- ActiveRecord::ConnectionAdapters::SchemaCache
- ActiveRecord::ConnectionAdapters::Sqlserver::SchemaCache
- Defined in:
- lib/active_record/connection_adapters/sqlserver/schema_cache.rb
Instance Attribute Summary collapse
-
#view_information(table_name) ⇒ Object
readonly
Returns the value of attribute view_information.
Instance Method Summary collapse
- #clear! ⇒ Object
- #clear_table_cache!(table_name) ⇒ Object
-
#initialize(conn) ⇒ SchemaCache
constructor
A new instance of SchemaCache.
- #quote_name(name, split_on_dots = true) ⇒ Object
-
#table_exists?(table_name) ⇒ Boolean
Superclass Overrides.
-
#table_names ⇒ Object
SQL Server Specific.
- #view_exists?(table_name) ⇒ Boolean
- #view_names ⇒ Object
Constructor Details
#initialize(conn) ⇒ SchemaCache
Returns a new instance of SchemaCache.
7 8 9 10 11 12 13 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 7 def initialize(conn) super @table_names = nil @view_names = nil @view_information = {} @quoted_names = {} end |
Instance Attribute Details
#view_information(table_name) ⇒ Object (readonly)
Returns the value of attribute view_information.
5 6 7 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 5 def view_information @view_information end |
Instance Method Details
#clear! ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 24 def clear! super @table_names = nil @view_names = nil @view_information.clear @quoted_names.clear end |
#clear_table_cache!(table_name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 32 def clear_table_cache!(table_name) key = table_name_key(table_name) super(key) super(table_name) # SQL Server Specific if @table_names @table_names.delete key @table_names.delete table_name end if @view_names @view_names.delete key @view_names.delete table_name end @view_information.delete key end |
#quote_name(name, split_on_dots = true) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 68 def quote_name(name, split_on_dots = true) return @quoted_names[name] if @quoted_names.key? name @quoted_names[name] = if split_on_dots name.to_s.split('.').map { |n| quote_name_part(n) }.join('.') else quote_name_part(name.to_s) end end |
#table_exists?(table_name) ⇒ Boolean
Superclass Overrides
17 18 19 20 21 22 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 17 def table_exists?(table_name) return false if table_name.blank? key = table_name_key(table_name) return @tables[key] if @tables.key? key @tables[key] = connection.table_exists?(table_name) end |
#table_names ⇒ Object
SQL Server Specific
50 51 52 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 50 def table_names @table_names ||= connection.tables end |
#view_exists?(table_name) ⇒ Boolean
58 59 60 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 58 def view_exists?(table_name) table_exists?(table_name) end |
#view_names ⇒ Object
54 55 56 |
# File 'lib/active_record/connection_adapters/sqlserver/schema_cache.rb', line 54 def view_names @view_names ||= connection.views end |