Module: SchemaPlus::ActiveRecord::Base::ClassMethods
- Defined in:
- lib/schema_plus/active_record/base.rb
Overview
:nodoc:
Class Method Summary collapse
-
.extended(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#columns_with_schema_plus ⇒ Object
:nodoc:.
-
#foreign_keys ⇒ Object
Returns a list of ForeignKeyDefinition objects, for each foreign key constraint defined in this model’s table.
-
#indexes ⇒ Object
Returns a list of IndexDefinition objects, for each index defind on this model’s table.
-
#reset_column_information_with_schema_plus ⇒ Object
:nodoc:.
-
#reverse_foreign_keys ⇒ Object
Returns a list of ForeignKeyDefinition objects, for each foreign key constraint of other tables that refer to this model’s table.
Class Method Details
.extended(base) ⇒ Object
:nodoc:
13 14 15 16 17 18 |
# File 'lib/schema_plus/active_record/base.rb', line 13 def self.extended(base) #:nodoc: class << base alias_method_chain :columns, :schema_plus alias_method_chain :reset_column_information, :schema_plus end end |
Instance Method Details
#columns_with_schema_plus ⇒ Object
:nodoc:
22 23 24 25 26 |
# File 'lib/schema_plus/active_record/base.rb', line 22 def columns_with_schema_plus #:nodoc: columns = columns_without_schema_plus columns.each do |column| column.model = self end unless @schema_plus_extended_columns columns end |
#foreign_keys ⇒ Object
Returns a list of ForeignKeyDefinition objects, for each foreign key constraint defined in this model’s table
41 42 43 |
# File 'lib/schema_plus/active_record/base.rb', line 41 def foreign_keys @foreign_keys ||= connection.foreign_keys(table_name, "#{name} Foreign Keys") end |
#indexes ⇒ Object
Returns a list of IndexDefinition objects, for each index defind on this model’s table.
35 36 37 |
# File 'lib/schema_plus/active_record/base.rb', line 35 def indexes @indexes ||= connection.indexes(table_name, "#{name} Indexes") end |
#reset_column_information_with_schema_plus ⇒ Object
:nodoc:
28 29 30 31 |
# File 'lib/schema_plus/active_record/base.rb', line 28 def reset_column_information_with_schema_plus #:nodoc: reset_column_information_without_schema_plus @indexes = @foreign_keys = @schema_plus_extended_columns = nil end |
#reverse_foreign_keys ⇒ Object
Returns a list of ForeignKeyDefinition objects, for each foreign key constraint of other tables that refer to this model’s table
47 48 49 |
# File 'lib/schema_plus/active_record/base.rb', line 47 def reverse_foreign_keys connection.reverse_foreign_keys(table_name, "#{name} Reverse Foreign Keys") end |