Class: EnumGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- EnumGenerator
- Extended by:
- EnumGeneratorHelpers::MigrationNumber
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/enum/enum_generator.rb
Overview
Generator for PowerEnum
Instance Method Summary collapse
-
#generate_migration ⇒ Object
Generates the migration to create the enum table.
-
#generate_model ⇒ Object
Generates the enum ActiveRecord model.
-
#pluralize_table_names? ⇒ Boolean
Do not pluralize enumeration names.
Methods included from EnumGeneratorHelpers::MigrationNumber
Instance Method Details
#generate_migration ⇒ Object
Generates the migration to create the enum table.
23 24 25 26 |
# File 'lib/generators/enum/enum_generator.rb', line 23 def generate_migration @description = .description? migration_template 'rails31_migration.rb.erb', "db/migrate/create_enum_#{table_name}.rb" if .migration? end |
#generate_model ⇒ Object
Generates the enum ActiveRecord model.
18 19 20 |
# File 'lib/generators/enum/enum_generator.rb', line 18 def generate_model template 'model.rb.erb', File.join('app/models', class_path, "#{file_name}.rb") end |
#pluralize_table_names? ⇒ Boolean
Do not pluralize enumeration names
29 30 31 |
# File 'lib/generators/enum/enum_generator.rb', line 29 def pluralize_table_names? false end |