Class: Riveter::Generators::CommandGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/riveter/command/command_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, *options) ⇒ CommandGenerator

Returns a new instance of CommandGenerator.



16
17
18
19
# File 'lib/generators/riveter/command/command_generator.rb', line 16

def initialize(args, *options)
  super
  parse_command_attributes!
end

Instance Method Details

#create_command_fileObject



21
22
23
# File 'lib/generators/riveter/command/command_generator.rb', line 21

def create_command_file
  template 'command.rb', File.join('app/commands', class_path, "#{file_name}_command.rb")
end

#create_locale_fileObject



30
31
32
# File 'lib/generators/riveter/command/command_generator.rb', line 30

def create_locale_file
  template 'commands.en.yml', File.join('config/locales', 'commands.en.yml') unless locale_file_exists?
end

#create_module_fileObject



25
26
27
28
# File 'lib/generators/riveter/command/command_generator.rb', line 25

def create_module_file
  return if regular_class_path.empty?
  template 'module.rb', File.join('app/commands', "#{class_path.join('/')}.rb") if behavior == :invoke
end