Class: Hanami::CLI::Commands::Generate::Action Private

Inherits:
Command
  • Object
show all
Defined in:
lib/hanami/cli/commands/generate/action.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.

Since:

  • 1.1.0

Instance Method Summary collapse

Methods inherited from Command

inherited, #initialize

Constructor Details

This class inherits a constructor from Hanami::CLI::Commands::Command

Instance Method Details

#call(app:, action:, **options) ⇒ 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.

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength

Since:

  • 1.1.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/hanami/cli/commands/generate/action.rb', line 32

def call(app:, action:, **options)
  *controller, action        = controller_and_action_name(action)
  classified_controller_name = classified_controller(controller)
  http_method                = route_http_method(action, options)
  context                    = Context.new(app: app, controller: controller, classified_controller_name: classified_controller_name, action: action, test: options.fetch(:test), http_method: http_method, options: options)
  context                    = context.with(template: project.template(context),
                                            action_class_definition: action_class_definition(context),
                                            view_class_definition: view_class_definition(context),
                                            beginning_module_definition: beginning_module_definition(context),
                                            ending_module_definition: ending_module_definition(context))

  assert_valid_app!(context)
  assert_valid_route_url!(context)
  assert_valid_route_http_method!(context)

  generate_action(context)
  generate_view(context)
  generate_template(context)
  generate_action_spec(context)
  generate_view_spec(context)
  insert_route(context)
end