Class: Hanami::CLI::Commands::App::Generate::Command Private

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

  • 2.2.0

Direct Known Subclasses

Migration, Operation, Relation

Constant Summary

Constants inherited from Command

Command::ACTION_SEPARATOR

Instance Method Summary collapse

Methods inherited from Command

#app, inherited, #measure, #run_command

Methods inherited from Hanami::CLI::Command

new

Constructor Details

#initialize(fs:, inflector:, **opts) ⇒ Command

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.

Returns a new instance of Command.

Since:

  • 2.2.0



24
25
26
27
28
29
30
31
# File 'lib/hanami/cli/commands/app/generate/command.rb', line 24

def initialize(
  fs:,
  inflector:,
  **opts
)
  super
  @generator = generator_class.new(fs: fs, inflector: inflector, out: out)
end

Instance Method Details

#call(name:, slice: nil) ⇒ 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.

Since:

  • 2.2.0



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hanami/cli/commands/app/generate/command.rb', line 40

def call(name:, slice: nil, **)
  if slice
    generator.call(
      key: name,
      namespace: slice,
      base_path: fs.join("slices", inflector.underscore(slice))
    )
  else
    generator.call(
      key: name,
      namespace: app.namespace,
      base_path: "app"
    )
  end
end

#generator_classObject

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.

Since:

  • 2.2.0



33
34
35
36
# File 'lib/hanami/cli/commands/app/generate/command.rb', line 33

def generator_class
  # Must be implemented by subclasses, with class that takes:
  # fs:, inflector:, out:
end