diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2012-05-16 15:08:17 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2012-05-16 15:19:59 -0700 |
commit | a57990ff51800bb05cebaf102e7d288487c98bd8 (patch) | |
tree | 8d30639532067f603e6be2b5d18b8e9e8b5f02b3 /activerecord/lib | |
parent | d6e4c06a8a995a572237ebca96fa1d320e2418b3 (diff) | |
download | rails-a57990ff51800bb05cebaf102e7d288487c98bd8.tar.gz rails-a57990ff51800bb05cebaf102e7d288487c98bd8.tar.bz2 rails-a57990ff51800bb05cebaf102e7d288487c98bd8.zip |
Call methods on the correct instance in AR::Schema.define
Now that migrations support instance methods, we should
use the same instance rather than relying on delegation
to a global instance. This allows subclassing AR::Schema.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/schema.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb index d815ab05ac..599e68379a 100644 --- a/activerecord/lib/active_record/schema.rb +++ b/activerecord/lib/active_record/schema.rb @@ -34,6 +34,15 @@ module ActiveRecord ActiveRecord::Migrator.migrations_paths end + def define(info, &block) + instance_eval(&block) + + unless info[:version].blank? + initialize_schema_migrations_table + assume_migrated_upto_version(info[:version], migrations_paths) + end + end + # Eval the given block. All methods available to the current connection # adapter are available within the block, so you can easily use the # database definition DSL to build up your schema (+create_table+, @@ -46,13 +55,7 @@ module ActiveRecord # ... # end def self.define(info={}, &block) - schema = new - schema.instance_eval(&block) - - unless info[:version].blank? - initialize_schema_migrations_table - assume_migrated_upto_version(info[:version], schema.migrations_paths) - end + new.define(info, &block) end end end |