Class: Drails::Generators::CommandGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Drails::Generators::CommandGenerator
- Defined in:
- lib/generators/drails/command/command_generator.rb
Instance Method Summary collapse
- #add_to_command_processor ⇒ Object
- #create_command_file ⇒ Object
- #create_command_processor ⇒ Object
- #create_related_event_file ⇒ Object
Instance Method Details
#add_to_command_processor ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/generators/drails/command/command_generator.rb', line 19 def add_to_command_processor content = " process #{class_name}Command do |command| command.is_valid_do { event #{class_name}Event.new command.to_hash } end" inject_into_file File.join('domain/command_processors', domain_ns, "#{processor_file_name}_processor.rb"), content, after: /(\s)*include(\s)*ActiveDomain::CommandProcessor/ end |
#create_command_file ⇒ Object
7 8 9 |
# File 'lib/generators/drails/command/command_generator.rb', line 7 def create_command_file template 'command.rb', File.join('app/commands', class_path, "#{file_name}_command.rb") end |
#create_command_processor ⇒ Object
15 16 17 |
# File 'lib/generators/drails/command/command_generator.rb', line 15 def create_command_processor generate 'drails:command_processor', processor_file_name, '-s' end |
#create_related_event_file ⇒ Object
11 12 13 |
# File 'lib/generators/drails/command/command_generator.rb', line 11 def template 'event.rb', File.join('app/events', class_path, "#{file_name}_event.rb") end |