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

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

Constant Summary

Constants inherited from Command

Command::ACTION_SEPARATOR

Instance Method Summary collapse

Methods inherited from Command

#app, #database, #database_config, inherited, #measure, #run_command

Methods inherited from Hanami::CLI::Command

new

Constructor Details

#initialize(fs:, inflector:, generator: Generators::App::Slice.new(fs: fs, inflector: inflector), **opts) ⇒ Slice

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 Slice.

Since:

  • 2.0.0



26
27
28
29
30
31
32
33
# File 'lib/hanami/cli/commands/app/generate/slice.rb', line 26

def initialize(
  fs:, inflector:,
  generator: Generators::App::Slice.new(fs: fs, inflector: inflector),
  **opts
)
  super(fs: fs, inflector: inflector, **opts)
  @generator = generator
end

Instance Method Details

#call(name:, url: 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.0.0



37
38
39
40
41
42
43
44
45
# File 'lib/hanami/cli/commands/app/generate/slice.rb', line 37

def call(name:, url: nil, **)
  require "hanami/setup"

  app = inflector.underscore(Hanami.app.namespace)
  name = inflector.underscore(Shellwords.shellescape(name))
  url = sanitize_url_prefix(name, url)

  generator.call(app, name, url)
end