Permalink
Browse files

Don't dirty up the command delegates' base class with methods that be…

…long in the migration generator class.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2799 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 85513e3 commit 41943847046e188261ebf2336f83f65fc4b80fbd @jeremy jeremy committed Oct 29, 2005
@@ -5,10 +5,8 @@ def manifest
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,16 +29,18 @@ def next_migration_number
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)
template(relative_source, "#{relative_destination}/#{next_migration_string}_#{file_name}.rb", template_options)
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)

0 comments on commit 4194384

Please sign in to comment.