Class: WatermelonDbSync::Generators::AddSyncFieldsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- WatermelonDbSync::Generators::AddSyncFieldsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Generates the next migration number with a timestamp.
Instance Method Summary collapse
- #copy_migrations ⇒ Object
-
#migration_class_name ⇒ Object
Generates the migration class name to use in the template.
-
#migration_file_name ⇒ Object
Generates the migration file name based on the model name.
Class Method Details
.next_migration_number(dirname) ⇒ Object
Generates the next migration number with a timestamp
17 18 19 |
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 17 def self.next_migration_number(dirname) Time.now.utc.strftime("%Y%m%d%H%M%S") end |
Instance Method Details
#copy_migrations ⇒ Object
11 12 13 14 |
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 11 def copy_migrations # Use the helper methods directly to set the migration file name and path migration_template "add_sync_fields_migration.rb.erb", "db/migrate/#{migration_file_name}.rb" end |
#migration_class_name ⇒ Object
Generates the migration class name to use in the template
27 28 29 |
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 27 def migration_class_name "AddSyncFieldsTo#{model_name.tableize.camelize}" end |
#migration_file_name ⇒ Object
Generates the migration file name based on the model name
22 23 24 |
# File 'lib/generators/watermelon_db_sync/add_sync_fields/add_sync_fields_generator.rb', line 22 def migration_file_name "add_sync_fields_to_#{model_name.tableize}" end |