Class: PgCron::Generators::MigrationHelper Private

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/pg_cron/migration_helper.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Chooses the migration template and filename.

Copied from Fx::Generators::MigrationHelper, minus the object_type argument: this gem has one kind of object, so the templates are named create_job / update_job rather than being interpolated per type.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MigrationHelper

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MigrationHelper.



13
14
15
# File 'lib/generators/pg_cron/migration_helper.rb', line 13

def initialize(options)
  @options = options
end

Instance Method Details

#migration_template_info(file_name:, updating_existing:, version:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/pg_cron/migration_helper.rb', line 25

def migration_template_info(file_name:, updating_existing:, version:)
  if updating_existing
    {
      template: "db/migrate/update_job.erb",
      filename: "db/migrate/update_cron_job_#{file_name}_to_version_#{version}.rb"
    }
  else
    {
      template: "db/migrate/create_job.erb",
      filename: "db/migrate/create_cron_job_#{file_name}.rb"
    }
  end
end

#skip_creation? ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


17
18
19
# File 'lib/generators/pg_cron/migration_helper.rb', line 17

def skip_creation?
  !should_create_migration?
end

#update_migration_class_name(class_name:, version:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/generators/pg_cron/migration_helper.rb', line 21

def update_migration_class_name(class_name:, version:)
  "UpdateCronJob#{class_name}ToVersion#{version}"
end