Class: PgCron::Generators::NameHelper Private
- Inherits:
-
Object
- Object
- PgCron::Generators::NameHelper
- Defined in:
- lib/generators/pg_cron/name_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.
Formats a job name for use in a generated migration.
Copied from Fx::Generators::NameHelper. F(x) quotes names containing a dot because a function or trigger can be schema-qualified; a pg_cron jobname is a plain string in cron.job and never is, but the same rule is kept so a name with a dot still produces valid Ruby rather than a stray constant.
Class Method Summary collapse
Class Method Details
.format_for_migration(name) ⇒ 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.
14 15 16 17 18 19 20 |
# File 'lib/generators/pg_cron/name_helper.rb', line 14 def self.format_for_migration(name) if name.include?(".") "\"#{name}\"" else ":#{name}" end end |
.validate_and_format(name) ⇒ 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.
22 23 24 25 26 |
# File 'lib/generators/pg_cron/name_helper.rb', line 22 def self.validate_and_format(name) raise ArgumentError, "Name cannot be blank" if name.blank? format_for_migration(name) end |