diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2011-11-11 02:47:27 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2011-11-11 02:47:27 +0530 |
commit | 6e112e42176c6842270f879fd15a0b7b7371ecef (patch) | |
tree | 14d6d75fb2fdd5c77b7d9d34f546d8bf502e355a /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | |
parent | 23101de283de13517e30c4c3d1ecc65525264886 (diff) | |
download | rails-6e112e42176c6842270f879fd15a0b7b7371ecef.tar.gz rails-6e112e42176c6842270f879fd15a0b7b7371ecef.tar.bz2 rails-6e112e42176c6842270f879fd15a0b7b7371ecef.zip |
Modify change_table to remove the need for the block argument.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index be9a02682b..11da84e245 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -241,14 +241,19 @@ module ActiveRecord # # See also Table for details on # all of the various column transformation - def change_table(table_name, options = {}) - if supports_bulk_alter? && options[:bulk] - recorder = ActiveRecord::Migration::CommandRecorder.new(self) - yield Table.new(table_name, recorder) - bulk_change_table(table_name, recorder.commands) - else - yield Table.new(table_name, self) + def change_table(table_name, options = {}, &blk) + bulk_change = supports_bulk_alter? && options[:bulk] + recorder = bulk_change ? ActiveRecord::Migration::CommandRecorder.new(self) : self + table = Table.new(table_name, recorder) + + if block_given? + if blk.arity == 1 + yield table + else + table.instance_eval(&blk) + end end + bulk_change_table(table_name, recorder.commands) if bulk_change end # Renames a table. |