Sha256: a368d6ade57f43a3df95fb6caef57f30986aa597e65421eb2bb84bf8dcaa1a61

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

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

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

      argument :value_objects, type: :array, default: [], banner: 'value_object value_object'

      def call
        invoke Service::Generators::SetupGenerator, [name]

        value_objects.each do |u|
          @value_object = u.classify
          create_main(u)
        end
      end

      private

      def create_main(m)
        path = "#{service_path}/value_objects/#{m.underscore}.rb"
        template 'value_object.rb.erb', path
      end

      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

1 entries across 1 versions & 1 rubygems

Version Path
command_service_object-1.3.0 lib/generators/service/value_object/value_object_generator.rb