Sha256: 927669448ebb3902ce08730d66101ff68e8efb96a2dc3494ab1696520bcd4d14

Contents?: true

Size: 1.15 KB

Versions: 113

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "rails/generators/named_base"

module Rails # :nodoc:
  module Generators # :nodoc:
    class JobGenerator < Rails::Generators::NamedBase # :nodoc:
      desc "This generator creates an active job file at app/jobs"

      class_option :queue, type: :string, default: "default", desc: "The queue name for the generated job"

      check_class_collision suffix: "Job"

      hook_for :test_framework

      def self.default_generator_root
        __dir__
      end

      def create_job_file
        template "job.rb", File.join("app/jobs", class_path, "#{file_name}_job.rb")

        in_root do
          if behavior == :invoke && !File.exist?(application_job_file_name)
            template "application_job.rb", application_job_file_name
          end
        end
      end

      private
        def file_name
          @_file_name ||= super.sub(/_job\z/i, "")
        end

        def application_job_file_name
          @application_job_file_name ||= if mountable_engine?
            "app/jobs/#{namespaced_path}/application_job.rb"
          else
            "app/jobs/application_job.rb"
          end
        end
    end
  end
end

Version data entries

113 entries across 109 versions & 9 rubygems

Version Path
activejob-7.0.8.6 lib/rails/generators/job/job_generator.rb
activejob-6.1.7.10 lib/rails/generators/job/job_generator.rb
activejob-6.1.7.9 lib/rails/generators/job/job_generator.rb
activejob-7.0.8.5 lib/rails/generators/job/job_generator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activejob-7.0.8.4/lib/rails/generators/job/job_generator.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/rails/generators/job/job_generator.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/rails/generators/job/job_generator.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/rails/generators/job/job_generator.rb
activejob-7.0.8.4 lib/rails/generators/job/job_generator.rb
activejob-6.1.7.8 lib/rails/generators/job/job_generator.rb
activejob-7.0.8.1 lib/rails/generators/job/job_generator.rb
activejob-6.1.7.7 lib/rails/generators/job/job_generator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-7.0.3.1/lib/rails/generators/job/job_generator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-7.0.2.3/lib/rails/generators/job/job_generator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/rails/generators/job/job_generator.rb
activejob-7.0.8 lib/rails/generators/job/job_generator.rb
activejob-7.0.7.2 lib/rails/generators/job/job_generator.rb
activejob-6.1.7.6 lib/rails/generators/job/job_generator.rb
activejob-7.0.7.1 lib/rails/generators/job/job_generator.rb
activejob-6.1.7.5 lib/rails/generators/job/job_generator.rb