Sha256: d16a346a1c3d8f8d2d04601d283c4a9b49a1fca109d6c21019f4e0bc54b725eb

Contents?: true

Size: 1.05 KB

Versions: 20

Compression:

Stored size: 1.05 KB

Contents

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
        File.dirname(__FILE__)
      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 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

20 entries across 20 versions & 1 rubygems

Version Path
activejob-5.1.7 lib/rails/generators/job/job_generator.rb
activejob-5.1.7.rc1 lib/rails/generators/job/job_generator.rb
activejob-5.1.6.2 lib/rails/generators/job/job_generator.rb
activejob-5.1.6.1 lib/rails/generators/job/job_generator.rb
activejob-5.1.6 lib/rails/generators/job/job_generator.rb
activejob-5.1.5 lib/rails/generators/job/job_generator.rb
activejob-5.1.5.rc1 lib/rails/generators/job/job_generator.rb
activejob-5.1.4 lib/rails/generators/job/job_generator.rb
activejob-5.1.4.rc1 lib/rails/generators/job/job_generator.rb
activejob-5.1.3 lib/rails/generators/job/job_generator.rb
activejob-5.1.3.rc3 lib/rails/generators/job/job_generator.rb
activejob-5.1.3.rc2 lib/rails/generators/job/job_generator.rb
activejob-5.1.3.rc1 lib/rails/generators/job/job_generator.rb
activejob-5.1.2 lib/rails/generators/job/job_generator.rb
activejob-5.1.2.rc1 lib/rails/generators/job/job_generator.rb
activejob-5.1.1 lib/rails/generators/job/job_generator.rb
activejob-5.1.0 lib/rails/generators/job/job_generator.rb
activejob-5.1.0.rc2 lib/rails/generators/job/job_generator.rb
activejob-5.1.0.rc1 lib/rails/generators/job/job_generator.rb
activejob-5.1.0.beta1 lib/rails/generators/job/job_generator.rb