Sha256: 4691fa3b6a68a97a381a272ea3efbf1d61df21d7c5cde7470cf436290af6ef10
Contents?: true
Size: 896 Bytes
Versions: 7
Compression:
Stored size: 896 Bytes
Contents
require 'rails/generators' module ConfigScripts # This class provides a generator for creating a config new script. class ConfigScriptGenerator < Rails::Generators::NamedBase source_root File.expand_path('../../../../templates', __FILE__) # 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. # # @return [Nil] 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 end end
Version data entries
7 entries across 7 versions & 1 rubygems