Sha256: 4043c44c65f360000054d3ca30f6f521d91c0d7ad6091dfcd489fb976a6dd3b7

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

require 'generators/transponder'

module Transponder
  module Generators
    class ServiceGenerator < Base
      class_option :module_name, type: :string, aliases: '-m', default: 'application'
      
      def add_service
        service_path = File.join(javascripts_path, options[:module_name], "services/#{file_name.downcase}.coffee")
        template "_service.coffee", service_path
      end

      def service_class_name
        "#{options[:module_name].camelize}.Services.#{file_name.camelize}"
      end

      def add_service_to_manifest
        manifest_file = File.join(javascripts_path, options[:module_name], 'initializers/manifest.coffee')
        insert_into_file manifest_file, 
                         "  $('body').trigger '#{options[:module_name].downcase}:services:#{file_name.downcase}'\n",
                         after: "#{options[:module_name].camelize}.services_manifest = ->\n"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transponder-2.0.0 lib/generators/transponder/service/service_generator.rb