Module: SchemaPlus::ActiveRecord::Base::ClassMethods

Defined in:
lib/schema_plus/active_record/base.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

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_plusObject

: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 ||= false)
  columns
end

#foreign_keysObject

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

#indexesObject

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_plusObject

: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_keysObject

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