Class: Correspondent::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Correspondent::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/correspondent/install/install_generator.rb
Overview
InstallGenerator
Creates the necessary migrations to be able to use the engine.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(_path) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/correspondent/install/install_generator.rb', line 17 def self.next_migration_number(_path) if @prev_migration_nr @prev_migration_nr += 1 else @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end @prev_migration_nr.to_s end |
Instance Method Details
#copy_migrations ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/correspondent/install/install_generator.rb', line 27 def copy_migrations migration_template "create_correspondent_notifications.rb", "db/migrate/create_correspondent_notifications.rb", migration_version: migration_version say "\n" say <<~POST_INSTALL_MESSAGE Make sure to edit the generated migration and adapt the notifications attributes according to the application's need. The only attributes that must be kept are the one listed below and the indices. Any other desired attributes can be added and then referenced in the `to_notification` method. publisher_type publisher_id subscriber_type subscriber_id POST_INSTALL_MESSAGE end |
#migration_version ⇒ Object
48 49 50 |
# File 'lib/generators/correspondent/install/install_generator.rb', line 48 def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end |