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
27
28
29
30
31
32
33
# File 'lib/schema_plus/active_record/base.rb', line 22

def columns_with_schema_plus #:nodoc:
  unless @schema_plus_extended_columns
    @schema_plus_extended_columns = true
    cols = columns_hash
    indexes.each do |index|
      index.columns.each do |name|
        cols[name].indexes << index
      end
    end
  end
  columns_without_schema_plus
end

#foreign_keysObject

Returns a list of ForeignKeyDefinition objects, for each foreign key constraint defined in this model’s table



48
49
50
# File 'lib/schema_plus/active_record/base.rb', line 48

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.



42
43
44
# File 'lib/schema_plus/active_record/base.rb', line 42

def indexes
  @indexes ||= connection.indexes(table_name, "#{name} Indexes")
end

#reset_column_information_with_schema_plusObject

:nodoc:



35
36
37
38
# File 'lib/schema_plus/active_record/base.rb', line 35

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



54
55
56
# File 'lib/schema_plus/active_record/base.rb', line 54

def reverse_foreign_keys
  connection.reverse_foreign_keys(table_name, "#{name} Reverse Foreign Keys")
end