Class: Flipper::Generators::ActiveRecordGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Flipper::Generators::ActiveRecordGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/flipper/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
15 16 17 |
# File 'lib/generators/flipper/active_record_generator.rb', line 15 def self.migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if requires_migration_number? end |
.next_migration_number(dirname) ⇒ Object
11 12 13 |
# File 'lib/generators/flipper/active_record_generator.rb', line 11 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end |
.requires_migration_number? ⇒ Boolean
19 20 21 |
# File 'lib/generators/flipper/active_record_generator.rb', line 19 def self.requires_migration_number? Rails::VERSION::MAJOR.to_i >= 5 end |
Instance Method Details
#create_migration_file ⇒ Object
23 24 25 26 27 28 |
# File 'lib/generators/flipper/active_record_generator.rb', line 23 def create_migration_file = { migration_version: migration_version, } migration_template 'migration.erb', 'db/migrate/create_flipper_tables.rb', end |
#migration_version ⇒ Object
30 31 32 |
# File 'lib/generators/flipper/active_record_generator.rb', line 30 def migration_version self.class.migration_version end |