Sha256: 413f7a2a2b8fa9459ccb32b7b52e649f3b76708a05c18b134c01efa3d5e8782d

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

require_relative '../setup/setup_generator.rb'
require_relative '../helper'

module Service
  module Generators
    class ListenerGenerator < Rails::Generators::NamedBase
      source_root File.expand_path('templates', __dir__)

      argument :listeners, type: :array, default: [], banner: 'Listener Listener'

      def setup
        invoke Service::Generators::SetupGenerator, [name]
      end

      def create_micros
        listeners.each do |m|
          @listener = m.classify

          path = "#{service_path}/listeners/#{m.underscore}.rb"
          template 'listener.rb.erb', path
        end
      end

      private

      def service_name
        Service::Helper.service_name(name)
      end

      def service_path
        Service::Helper.service_path(name)
      end

      def spec_path
        Service::Helper.spec_path(name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
command_service_object-1.3.0 lib/generators/service/listener/listener_generator.rb
command_service_object-1.2.1 lib/generators/service/listener/listener_generator.rb