Sha256: a66b533148c1d8b44fe81067abfe3478abda749052eae779055bb08776e22a81

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

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

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

      argument :queries, type: :array, default: [], banner: 'query query'

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

      def create_queries
        queries.each do |m|
          @query = m.classify

          path = "#{service_path}/queries/#{m.underscore}.rb"
          template 'query.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/query/query_generator.rb
command_service_object-1.2.1 lib/generators/service/query/query_generator.rb