Class: Emailbutler::Generators::ActiveRecordGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Emailbutler::Generators::ActiveRecordGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/emailbutler/active_record_generator.rb
Class Method Summary collapse
- .migration_version ⇒ Object
- .next_migration_number(dirname) ⇒ Object
- .requires_migration_number? ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.migration_version ⇒ Object
17 18 19 |
# File 'lib/generators/emailbutler/active_record_generator.rb', line 17 def self.migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if requires_migration_number? end |
.next_migration_number(dirname) ⇒ Object
13 14 15 |
# File 'lib/generators/emailbutler/active_record_generator.rb', line 13 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end |
.requires_migration_number? ⇒ Boolean
21 22 23 |
# File 'lib/generators/emailbutler/active_record_generator.rb', line 21 def self.requires_migration_number? Rails::VERSION::MAJOR.to_i >= 5 end |
Instance Method Details
#create_migration_file ⇒ Object
25 26 27 28 29 30 |
# File 'lib/generators/emailbutler/active_record_generator.rb', line 25 def create_migration_file = { migration_version: migration_version } migration_template 'migration.erb', 'db/migrate/create_emailbutler_tables.rb', end |
#migration_version ⇒ Object
32 33 34 |
# File 'lib/generators/emailbutler/active_record_generator.rb', line 32 def migration_version self.class.migration_version end |