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, 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



51
52
53
54
55
56
57
58
# File 'lib/hanami/cli/commands/app/generate/slice.rb', line 51

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, skip_db: SKIP_DB_DEFAULT, skip_route: DEFAULT_SKIP_ROUTE) ⇒ 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



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hanami/cli/commands/app/generate/slice.rb', line 62

def call(
  name:,
  url: nil,
  skip_db: SKIP_DB_DEFAULT,
  skip_route: DEFAULT_SKIP_ROUTE
)
  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, skip_db: skip_db, skip_route: skip_route)
end