14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/generators/nayati/workflow/workflow_generator.rb', line 14
def generate_workflow
raise "Workflow name must be passed" unless args.size == 1
workflow_name = args.first
underscored_workflow_name = Nayati::NameBasedConstantable.underscored_name(workflow_name)
master_workflow = Nayati::MasterWorkflow.new(underscored_workflow_name)
raise 'Workflow already exists' if master_workflow.exists?
master_workflow.save!
workflow_constant_name = Nayati::NameBasedConstantable.name_as_constant(underscored_workflow_name)
FileUtils.mkdir_p("#{Rails.root}/app/nayati_services")
service_file_path = "#{Rails.root}/app/nayati_services/#{underscored_workflow_name}_nayati_service.rb"
copy_file "nayati_service_template.txt", service_file_path
inject_into_file service_file_path, " #{workflow_constant_name}NayatiService\n", before: "\n def initialize"
end
|