diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-29 04:52:59 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-29 04:52:59 +0000 |
commit | 41943847046e188261ebf2336f83f65fc4b80fbd (patch) | |
tree | 6228a906ebbf619be0ffcaa58f259ccb5f3cdb09 /railties/lib/rails_generator/generators/components/migration | |
parent | 85513e37bf76bc79c0075da8b4d81c9c5f075b1d (diff) | |
download | rails-41943847046e188261ebf2336f83f65fc4b80fbd.tar.gz rails-41943847046e188261ebf2336f83f65fc4b80fbd.tar.bz2 rails-41943847046e188261ebf2336f83f65fc4b80fbd.zip |
Don't dirty up the command delegates' base class with methods that belong in the migration generator class.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2799 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/rails_generator/generators/components/migration')
-rw-r--r-- | railties/lib/rails_generator/generators/components/migration/migration_generator.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/railties/lib/rails_generator/generators/components/migration/migration_generator.rb b/railties/lib/rails_generator/generators/components/migration/migration_generator.rb index 65f5e6c74e..09674261da 100644 --- a/railties/lib/rails_generator/generators/components/migration/migration_generator.rb +++ b/railties/lib/rails_generator/generators/components/migration/migration_generator.rb @@ -5,10 +5,8 @@ class MigrationGenerator < Rails::Generator::NamedBase m.migration_template 'migration.rb', 'db/migrate' end end -end -module Rails::Generator::Commands - class Base + protected def existing_migrations(file_name) Dir.glob("db/migrate/[0-9]*_#{file_name}.rb") end @@ -31,9 +29,10 @@ module Rails::Generator::Commands def next_migration_string(padding = 3) "%.#{padding}d" % next_migration_number end - end +end - # When creating, it knows to find the first available file in db/migrate and use the migration.rb template. When deleting, it knows to delete every file named "[0-9]*_#{file_name}". +module Rails::Generator::Commands + # When creating, it knows to find the first available file in db/migrate and use the migration.rb template. class Create def migration_template(relative_source, relative_destination, template_options = {}) raise "Another migration is already named #{file_name}: #{existing_migrations(file_name).first}" if migration_exists?(file_name) @@ -41,6 +40,7 @@ module Rails::Generator::Commands end end + # When deleting, it knows to delete every file named "[0-9]*_#{file_name}". class Destroy def migration_template(relative_source, relative_destination, template_options = {}) raise "There is no migration named #{file_name}" unless migration_exists?(file_name) |