Sha256: a2fea190d9c79c1edd2186943f645cd9da88ea85ace41d6d8460d54f3b543189

Contents?: true

Size: 1001 Bytes

Versions: 17

Compression:

Stored size: 1001 Bytes

Contents

module SchemaPlus::ForeignKeys
  module ActiveRecord

    #
    # SchemaPlus::ForeignKeys adds several methods to ActiveRecord::Base
    #
    module Base
      module ClassMethods #:nodoc:

        public

        # Returns a list of ForeignKeyDefinition objects, for each foreign
        # key constraint defined in this model's table
        #
        # (memoized result gets reset in Middleware::Model::ResetColumnInformation)
        def foreign_keys
          @foreign_keys ||= connection.foreign_keys(table_name, "#{name} Foreign Keys")
        end

        def reset_foreign_key_information
          @foreign_keys = @reverse_foreign_keys = nil
        end

        # Returns a list of ForeignKeyDefinition objects, for each foreign
        # key constraint of other tables that refer to this model's table
        def reverse_foreign_keys
          @reverse_foreign_keys ||= connection.reverse_foreign_keys(table_name, "#{name} Reverse Foreign Keys")
        end

      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
schema_plus_foreign_keys-0.1.8 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.7 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.6 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.5 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.4 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.3 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.2 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.1 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus_foreign_keys-0.1.0 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre15 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre14 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre13 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre12 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre11 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre10 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre9 lib/schema_plus/foreign_keys/active_record/base.rb
schema_plus-2.0.0.pre8 lib/schema_plus/foreign_keys/active_record/base.rb