Class: ArchiveHookGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ArchiveHookGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/archive_hook/archive_hook_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #archive_table_name ⇒ Object
- #copy_archive_hook_migration ⇒ Object
- #migration_file_name ⇒ Object
- #migration_version ⇒ Object
Class Method Details
.next_migration_number(_dir_name) ⇒ Object
10 11 12 |
# File 'lib/generators/archive_hook/archive_hook_generator.rb', line 10 def self.next_migration_number(_dir_name) Time.now.utc.to_s.tr('^0-9', '')[0..13] end |
Instance Method Details
#archive_table_name ⇒ Object
18 19 20 |
# File 'lib/generators/archive_hook/archive_hook_generator.rb', line 18 def archive_table_name "#{table_name}_archive" end |
#copy_archive_hook_migration ⇒ Object
6 7 8 |
# File 'lib/generators/archive_hook/archive_hook_generator.rb', line 6 def copy_archive_hook_migration migration_template "migration.rb", migration_file_name, migration_version: migration_version, archive_table_name: archive_table_name end |
#migration_file_name ⇒ Object
14 15 16 |
# File 'lib/generators/archive_hook/archive_hook_generator.rb', line 14 def migration_file_name "db/migrate/create_#{archive_table_name}.rb" end |
#migration_version ⇒ Object
22 23 24 25 26 |
# File 'lib/generators/archive_hook/archive_hook_generator.rb', line 22 def migration_version if Rails::VERSION::MAJOR >= 5 "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end |