aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/rails
diff options
context:
space:
mode:
authorAbdelkader Boudih <terminale@gmail.com>2014-08-12 09:17:19 +0000
committerAbdelkader Boudih <terminale@gmail.com>2014-08-12 09:17:19 +0000
commita75f085941b2d6aed160f5f2f7e64e5fc7e03826 (patch)
tree23174b264983a15c3108ec912b355829c5f17a80 /activejob/lib/rails
parentb45b99894a60eda434abec94d133a1cfd8de2dda (diff)
parent14f74a8331f94150dfee653224de8fc837797709 (diff)
downloadrails-a75f085941b2d6aed160f5f2f7e64e5fc7e03826.tar.gz
rails-a75f085941b2d6aed160f5f2f7e64e5fc7e03826.tar.bz2
rails-a75f085941b2d6aed160f5f2f7e64e5fc7e03826.zip
Add 'activejob/' from commit '14f74a8331f94150dfee653224de8fc837797709'
git-subtree-dir: activejob git-subtree-mainline: b45b99894a60eda434abec94d133a1cfd8de2dda git-subtree-split: 14f74a8331f94150dfee653224de8fc837797709
Diffstat (limited to 'activejob/lib/rails')
-rw-r--r--activejob/lib/rails/generators/active_job/job_generator.rb22
-rw-r--r--activejob/lib/rails/generators/active_job/templates/job.rb9
2 files changed, 31 insertions, 0 deletions
diff --git a/activejob/lib/rails/generators/active_job/job_generator.rb b/activejob/lib/rails/generators/active_job/job_generator.rb
new file mode 100644
index 0000000000..fe4af0d2cc
--- /dev/null
+++ b/activejob/lib/rails/generators/active_job/job_generator.rb
@@ -0,0 +1,22 @@
+require 'rails/generators/named_base'
+
+module ActiveJob
+ 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'
+
+ def self.default_generator_root
+ File.dirname(__FILE__)
+ end
+
+ check_class_collision suffix: 'Job'
+
+ def create_job_file
+ template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb")
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/activejob/lib/rails/generators/active_job/templates/job.rb b/activejob/lib/rails/generators/active_job/templates/job.rb
new file mode 100644
index 0000000000..6a21616d30
--- /dev/null
+++ b/activejob/lib/rails/generators/active_job/templates/job.rb
@@ -0,0 +1,9 @@
+<% module_namespacing do -%>
+class <%= class_name %>Job < ActiveJob::Base
+ queue_as :<%= options[:queue] %>
+
+ def perform
+ # Do something later
+ end
+end
+<% end -%> \ No newline at end of file