Class: ConfigScripts::ConfigScriptGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/config_scripts/generators/config_script.rb

Overview

This class provides a generator for creating a config new script.

Instance Method Summary collapse

Instance Method Details

#config_scriptNil

This method creates a new config script.

It will take a template file from templates/config_scripts, and the name passed in when runing the generator, and create a file under db/config_scripts in the app.

The config script filename will be prefixed with a timestamp, like a database migration. The class defined in the config script will have the name passed in to the generator.

Returns:

  • (Nil)


18
19
20
21
22
# File 'lib/config_scripts/generators/config_script.rb', line 18

def config_script
  path = "db/config_scripts/#{Time.now.to_s(:number)}_#{self.file_name}.rb"
  template "config_script.rb", path, {name: name}
  nil
end