Sha256: 9fad09cfb9999f250dbdc936290e9f36bf15d092582ce3b110de9061293c6bb4

Contents?: true

Size: 781 Bytes

Versions: 16

Compression:

Stored size: 781 Bytes

Contents

require_relative '../setup/setup_generator.rb'

module Service
  module Generators
    class CommandGenerator < Rails::Generators::NamedBase
      include CommandServiceObject::ModelHelper

      source_root File.expand_path('templates', __dir__)

      argument :commands, type: :array, default: [], banner: 'command command'

      def call
        invoke Service::Generators::SetupGenerator, [name]
        @model_attributes = model_attributes
        commands.each do |c|
          @command = c.classify
          path = "app/services/#{service_name}/commands/#{c.underscore}.rb"
          template 'command.rb.erb', path unless options.skip_command?
        end
      end

      private

      def service_name
        "#{name.underscore}_service"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
command_service_object-0.6.5 lib/generators/service/command/command_generator.rb
command_service_object-0.6.4 lib/generators/service/command/command_generator.rb
command_service_object-0.6.3 lib/generators/service/command/command_generator.rb
command_service_object-0.6.2 lib/generators/service/command/command_generator.rb
command_service_object-0.6.1 lib/generators/service/command/command_generator.rb
command_service_object-0.6.0 lib/generators/service/command/command_generator.rb
command_service_object-0.5.11 lib/generators/service/command/command_generator.rb
command_service_object-0.5.10 lib/generators/service/command/command_generator.rb
command_service_object-0.5.9 lib/generators/service/command/command_generator.rb
command_service_object-0.5.8 lib/generators/service/command/command_generator.rb
command_service_object-0.5.7 lib/generators/service/command/command_generator.rb
command_service_object-0.5.6 lib/generators/service/command/command_generator.rb
command_service_object-0.5.5 lib/generators/service/command/command_generator.rb
command_service_object-0.5.2 lib/generators/service/command/command_generator.rb
command_service_object-0.5.1 lib/generators/service/command/command_generator.rb
command_service_object-0.5.0 lib/generators/service/command/command_generator.rb