Class: Rails::Generators::ServiceGenerator

Inherits:
NamedBase
  • Object
show all
Defined in:
lib/rails/generators/service/service_generator.rb

Overview

Create AppicationService and SubService classes using Rails generators.

E.g: bin/rails service my_service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_generator_rootObject



15
16
17
# File 'lib/rails/generators/service/service_generator.rb', line 15

def self.default_generator_root
  __dir__
end

Instance Method Details

#create_service_fileObject



19
20
21
22
23
24
25
26
27
# File 'lib/rails/generators/service/service_generator.rb', line 19

def create_service_file
  template 'service.rb', File.join('app/services', class_path, "#{file_name}.rb")

  in_root do
    if behavior == :invoke && !File.exist?(application_service_file_name)
      template 'application_service.rb', application_service_file_name
    end
  end
end