Class: Rivulet::CLI::Commands::Generate::Handler::Operation

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

Instance Method Summary collapse

Instance Method Details

#call(name:) ⇒ Object



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

def call(name:, **)
  handler_name, operation_name = name.split('.')
  handler_dir      = underscore(handler_name)
  operation_dir    = underscore(operation_name)
  handler_module   = camelize(handler_dir)
  operation_module = camelize(operation_dir)
  base             = "app/handlers/#{handler_dir}"

  write "#{base}/operations/#{operation_dir}.rb", operation_template(handler_module, operation_module)
  register_operation(base, handler_dir, handler_module, operation_dir, operation_module)
end