Sha256: 61b7ad5d7013f2e9dfe6d621b7a9b13e83b896b8a93c0209b98c983f6e723e70

Contents?: true

Size: 1.19 KB

Versions: 17

Compression:

Stored size: 1.19 KB

Contents

require 'rails/generators'
require 'rails/generators/active_record'

module ExternalServices
  module Generators
    # Installs ExternalServices in a rails app.
    class ServiceGenerator < ::Rails::Generators::NamedBase
      source_root File.expand_path('../templates/services', __FILE__)

      class_option(
        :only_api_actions,
        type: :boolean,
        default: false,
        desc: 'Do not generate service model class'
      )

      desc 'Generates specified model and API classes.'

      def add_model
        return if options.only_api_actions?

        dir = File.expand_path('app/models/external_services')
        template 'model.rb', File.join(dir, "#{file_name}.rb")
      end

      def add_api_action
        dir = File.expand_path('app/models/external_services/api_actions')
        template 'api_action.rb', File.join(dir, "#{file_name}.rb")
      end

      def add_api
        dir = File.expand_path('lib/external_services/api')
        template 'api.rb', File.join(dir, "#{file_name}.rb")
      end

      def add_api_job
        dir = File.expand_path('app/jobs/external_services')
        template 'api_job.rb', File.join(dir, "#{file_name}_api_job.rb")
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
external_services-0.4.4 lib/generators/service_generator.rb
external_services-0.4.3 lib/generators/service_generator.rb
external_services-0.4.2 lib/generators/service_generator.rb
external_services-0.4.1 lib/generators/service_generator.rb
external_services-0.4.0 lib/generators/service_generator.rb
external_services-0.3.1 lib/generators/service_generator.rb
external_services-0.3.0 lib/generators/service_generator.rb
external_services-0.2.4 lib/generators/service_generator.rb
external_services-0.2.3 lib/generators/service_generator.rb
external_services-0.2.2 lib/generators/service_generator.rb
external_services-0.2.1 lib/generators/service_generator.rb
external_services-0.2.0 lib/generators/service_generator.rb
external_services-0.1.9 lib/generators/service_generator.rb
external_services-0.1.8 lib/generators/service_generator.rb
external_services-0.1.7 lib/generators/service_generator.rb
external_services-0.1.6 lib/generators/service_generator.rb
external_services-0.1.5 lib/generators/service_generator.rb