From 41943847046e188261ebf2336f83f65fc4b80fbd Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 29 Oct 2005 04:52:59 +0000 Subject: 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 --- .../generators/components/migration/migration_generator.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'railties/lib/rails_generator') 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) -- cgit v1.2.3