Class: Paradigm::Generators::ServiceGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
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_rootObject



31
32
33
# File 'lib/generators/paradigm/service_generator.rb', line 31

def self.source_root
  @source_root ||= File.expand_path('../../templates/service', __FILE__)
end

Instance Method Details

#create_serviceObject



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