Class: Hanami::CliSubCommands::Destroy

Inherits:
Thor
  • Object
show all
Extended by:
Hanami::CliBase
Includes:
Thor::Actions
Defined in:
lib/hanami/cli_sub_commands/destroy.rb

Instance Method Summary collapse

Methods included from Hanami::CliBase

define_commands

Instance Method Details

#actions(application_name = nil, controller_and_action_name) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hanami/cli_sub_commands/destroy.rb', line 28

def actions(application_name = nil, controller_and_action_name)
  if Hanami::Environment.new(options).container? && application_name.nil?
    msg = "ERROR: \"hanami destroy action\" was called with arguments [\"#{controller_and_action_name}\"]\n" \
          "Usage: \"hanami action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME\""
    fail Error, msg
  end

  if options[:help]
    invoke :help, ['action']
  else
    Hanami::Commands::Generate::Action.new(options, application_name, controller_and_action_name).destroy.start
  end
end

#application(name) ⇒ Object


81
82
83
84
85
86
87
88
# File 'lib/hanami/cli_sub_commands/destroy.rb', line 81

def application(name)
  if options[:help]
    invoke :help, ['app']
  else
    require 'hanami/commands/generate/app'
    Hanami::Commands::Generate::App.new(options, name).destroy.start
  end
end

#mailer(name) ⇒ Object


97
98
99
100
101
102
103
104
105
106
# File 'lib/hanami/cli_sub_commands/destroy.rb', line 97

def mailer(name)
  if options[:help]
    invoke :help, ['mailer']
  else
    require 'hanami/commands/generate/mailer'

    options[:behavior] = :revoke
    Hanami::Commands::Generate::Mailer.new(options, name).destroy.start
  end
end

#migration(name) ⇒ Object


49
50
51
52
53
54
55
56
# File 'lib/hanami/cli_sub_commands/destroy.rb', line 49

def migration(name)
  if options[:help]
    invoke :help, ['migration']
  else
    require 'hanami/commands/generate/migration'
    Hanami::Commands::Generate::Migration.new(options, name).destroy.start
  end
end

#model(name) ⇒ Object


66
67
68
69
70
71
72
73
# File 'lib/hanami/cli_sub_commands/destroy.rb', line 66

def model(name)
  if options[:help]
    invoke :help, ['model']
  else
    require 'hanami/commands/generate/model'
    Hanami::Commands::Generate::Model.new(options, name).destroy.start
  end
end