Class: Rivulet::CLI::Commands::Generate::Service::Operation

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/rivulet/cli/generate/service/operation.rb

Instance Method Summary collapse

Instance Method Details

#call(name:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rivulet/cli/generate/service/operation.rb', line 12

def call(name:, **)
  service_name, operation_name = name.split('.')
  service_dir      = underscore(service_name)
  operation_dir    = underscore(operation_name)
  service_module   = camelize(service_dir)
  operation_module = camelize(operation_dir)
  base             = "app/services/#{service_dir}"

  mkdir "#{base}/projections"
  write "#{base}/operations/#{operation_dir}.rb", operation_template(service_module, operation_module)
  write "#{base}/contracts/#{operation_dir}.rb",  contract_template(service_module, operation_module)
  register_operation(base, service_dir, service_module, operation_dir, operation_module)
end