class ConfigScripts::MigrationsGenerator
This class provides a generator for creating the migrations that we need to use this gem.
Public Class Methods
next_migration_number(dirname)
click to toggle source
This method gets the number for the next migration created by this generator.
@param [String] dirname
The name of the directory in which we are creating the migrations.
We use the current timestamp.
# File lib/config_scripts/generators/migrations.rb, line 21 def self.next_migration_number(dirname) Time.now.to_s(:number) end
Public Instance Methods
create_migrations()
click to toggle source
This generator creates the migrations that we need for the gem.
# File lib/config_scripts/generators/migrations.rb, line 10 def create_migrations copy_migration 'create_config_scripts' end
Protected Instance Methods
copy_migration(filename)
click to toggle source
This method copies a migration from our template directory to the app’s migrations directory.
@param [String] filename
The name of the file in the templates directory.
# File lib/config_scripts/generators/migrations.rb, line 32 def copy_migration(filename) migration_template "#{filename}_migration.rb", "db/migrate/#{filename}.rb" end