2014-06-29 11:59:38 -04:00
|
|
|
require 'rails/generators/named_base'
|
|
|
|
|
2014-08-12 06:53:46 -04:00
|
|
|
module Rails
|
2014-06-29 11:59:38 -04:00
|
|
|
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'
|
|
|
|
|
2014-08-22 15:30:36 -04:00
|
|
|
check_class_collision suffix: 'Job'
|
|
|
|
|
|
|
|
hook_for :test_framework
|
|
|
|
|
2014-06-29 11:59:38 -04:00
|
|
|
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")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-08-12 06:53:46 -04:00
|
|
|
end
|