Class: Jets::CLI::Generate::Event

Inherits:
Jets::CLI::Group::Base show all
Defined in:
lib/jets/cli/generate/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Jets::CLI::Group::Helpers

#class_name, #framework, #init_project_name, #package_type, #underscore_name

Methods included from Jets::CLI::Group::Actions

#comment_out_line, #config_environment, #environment, #optimize_indentation

Class Method Details

.cli_optionsObject



5
6
7
8
9
10
11
# File 'lib/jets/cli/generate/event.rb', line 5

def self.cli_options
  [
    [:force, aliases: :f, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
    [:method, aliases: :m, desc: "Method name", default: "handle"],
    [:trigger, aliases: :t, desc: "Event trigger", default: "scheduled"]
  ]
end

Instance Method Details

#application_eventObject



18
19
20
# File 'lib/jets/cli/generate/event.rb', line 18

def application_event
  template "application_event.rb", "app/events/application_event.rb", skip: true
end

#eventObject



22
23
24
25
26
27
# File 'lib/jets/cli/generate/event.rb', line 22

def event
  trigger = options[:trigger]
  trigger = "scheduled" if trigger == "schedule" # allow both to work
  template_path = "#{trigger}.rb.tt"
  template template_path, "app/events/#{underscore_name}_event.rb"
end