Class: E621ExportDownloader::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/e621_export_downloader/install_generator.rb

Overview

Rails generator used for setting up E621ExportDownloader tables in a Rails application. Run it with bin/rails g e621_export_downloader:install in your console.

Constant Summary collapse

TEMPLATES =
File.join(File.dirname(__FILE__), "templates")

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



31
32
33
# File 'lib/generators/e621_export_downloader/install_generator.rb', line 31

def create_initializer
  template("initializers/e621_models.rb.erb", "config/initializers/e621_models.rb")
end

#create_migration_fileObject



27
28
29
# File 'lib/generators/e621_export_downloader/install_generator.rb', line 27

def create_migration_file
  migration_template("migrations/create_e621_tables.rb.erb", File.join(db_migrate_path, "create_e621_tables.rb"))
end

#validate_optionsObject



22
23
24
25
# File 'lib/generators/e621_export_downloader/install_generator.rb', line 22

def validate_options
  return if %w[schema prefix].include?(options[:table_format])
  abort("--table-format must be 'schema' or 'prefix', got '#{options[:table_format]}'")
end