Class: Drails::Generators::CommandGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Drails::Generators::CommandGenerator
- Includes:
- Domain, EventName, ProcessorName
- 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
Methods included from Domain
Methods included from EventName
Methods included from ProcessorName
Instance Method Details
#add_to_command_processor ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/drails/command/command_generator.rb', line 28 def add_to_command_processor return if skip_processor? content = " process #{class_name}Command do |command| command.is_valid_do { event #{event_class_name}Event.new command.to_hash } end" file = File.join('domain/command_processors', processor_domain_class_path, "#{processor_file_name}_processor.rb") inject_into_file file, content, after: /(\s)*include(\s)*ActiveDomain::CommandProcessor/ end |
#create_command_file ⇒ Object
14 15 16 |
# File 'lib/generators/drails/command/command_generator.rb', line 14 def create_command_file template 'command.rb', File.join('app/commands', class_path, "#{file_name}_command.rb") end |
#create_command_processor ⇒ Object
23 24 25 26 |
# File 'lib/generators/drails/command/command_generator.rb', line 23 def create_command_processor return if skip_processor? generate 'drails:command_processor', processor_file_path, '-s', '--skip-namespace' end |
#create_related_event_file ⇒ Object
18 19 20 21 |
# File 'lib/generators/drails/command/command_generator.rb', line 18 def return if skip_event? template 'event.rb', File.join('app/events', event_class_path, "#{event_file_name}_event.rb") end |