Class: Cmdx::WorkflowGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/cmdx/workflow_generator.rb

Overview

Generates CMDx workflow files for Rails applications

This generator creates task classes that inherit from either ApplicationTask (if defined) or CMDx::Task. It generates the task file in the standard Rails tasks directory structure.

Instance Method Summary collapse

Instance Method Details

#copy_filesvoid

This method returns an undefined value.

Copies the task template to the Rails application

Creates a new task file at ‘app/tasks//[file_name].rb` using the task template. The file is placed in the standard Rails tasks directory structure, maintaining proper namespacing if the task is nested.

Examples:

Basic usage

rails generate cmdx:workflow SendNotifications
# => Creates app/tasks/send_notifications.rb

Nested task

rails generate cmdx:workflow Admin::SendNotifications
# => Creates app/tasks/admin/send_notifications.rb


30
31
32
33
# File 'lib/generators/cmdx/workflow_generator.rb', line 30

def copy_files
  path = File.join("app/tasks", class_path, "#{file_name}.rb")
  template("workflow.rb.tt", path)
end