Sha256: 2264187a6001663c7e48540d9a4a90343dadcb05eadf43411db0aef57ec208c7

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

module SchemaPlusForeignKeys
  module ActiveRecord
    module Schema #:nodoc: all
      def self.included(base)
        base.extend(ClassMethods)
      end

      module ClassMethods
        def self.extended(base)
          class << base
            alias_method_chain :define, :schema_plus_foreign_keys
          end
        end

        def define_with_schema_plus_foreign_keys(info={}, &block)
          fk_override = { :auto_create => false, :auto_index => false }
          save = Hash[fk_override.keys.collect{|key| [key, SchemaPlusForeignKeys.config.send(key)]}]
          begin
            SchemaPlusForeignKeys.config.update_attributes(fk_override)
            define_without_schema_plus_foreign_keys(info, &block)
          ensure
            SchemaPlusForeignKeys.config.update_attributes(save)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schema_plus-2.0.0.pre3 lib/schema_plus_foreign_keys/active_record/schema.rb