Class: InteractorGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/ccios/interactor_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ InteractorGenerator

Returns a new instance of InteractorGenerator.



6
7
8
# File 'lib/ccios/interactor_generator.rb', line 6

def initialize(parser)
  @parser = parser
end

Instance Method Details

#generate(interactor_name, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ccios/interactor_generator.rb', line 10

def generate(interactor_name, options = {})
  interactor_group = @parser.interactor_group
  new_group_name = "#{interactor_name}Interactor"
  raise "[Error] Group #{new_group_name} already exists in #{app_group.display_name}" if interactor_group[new_group_name]
  new_group = interactor_group.new_group(new_group_name)

  file_creator = FileCreator.new(@parser.source_path, options)
  target = @parser.main_target
  file_creator.create_file(interactor_name, 'Interactor', new_group, target)
  file_creator.create_file(interactor_name, 'InteractorImplementation', new_group, target)

  file_creator.print_file_content(interactor_name, 'InteractorAssembly')
end