Sha256: 8fdcd6848a04ebe8301db9679fc58a2176d60df2c1969fc4c52be833fa24715d

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 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 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.4.1 lib/generators/service/query/query_generator.rb
command_service_object-1.4.0 lib/generators/service/query/query_generator.rb