Module: SchemaPlus::ActiveRecord::Schema::ClassMethods

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


9
10
11
12
13
# File 'lib/schema_plus/active_record/schema.rb', line 9

def self.extended(base)
  class << base
    alias_method_chain :define, :schema_plus
  end
end

Instance Method Details

#define_with_schema_plus(info = {}, &block) ⇒ Object


15
16
17
18
19
20
21
22
23
24
# File 'lib/schema_plus/active_record/schema.rb', line 15

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