Class: Paradigm::Generators::ServiceGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Paradigm::Generators::ServiceGenerator
- Defined in:
- lib/generators/paradigm/service_generator.rb
Constant Summary collapse
- SINGLE_COLON =
':'.freeze
- DOUBLE_COLON =
'::'.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
31 32 33 |
# File 'lib/generators/paradigm/service_generator.rb', line 31 def self.source_root @source_root ||= File.('../../templates/service', __FILE__) end |
Instance Method Details
#create_service ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/paradigm/service_generator.rb', line 35 def create_service @service_name = service_name if scoped_service_containing?(DOUBLE_COLON) use_scoped_templates(DOUBLE_COLON) elsif scoped_service_containing?(SINGLE_COLON) use_scoped_templates(SINGLE_COLON) else template 'service.rb', "app/services/#{service_name.underscore}_service.rb" template 'service_test.rb', "test/services/#{service_name.underscore}_service_test.rb" end end |