Class: DelayedJobGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/delayed_job/delayed_job_generator.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) next_migration_number(dirname)

Implement the required interface for Rails::Generators::Migration.



14
15
16
17
18
19
20
21
# File 'lib/generators/delayed_job/delayed_job_generator.rb', line 14

def self.next_migration_number(dirname) #:nodoc:
  next_migration_number = current_migration_number(dirname) + 1
  if ActiveRecord::Base.timestamped_migrations
    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
  else
    "%.3d" % next_migration_number
  end
end

+ (Object) source_root



8
9
10
# File 'lib/generators/delayed_job/delayed_job_generator.rb', line 8

def self.source_root
   @source_root ||= File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

- (Object) create_migration_file



28
29
30
31
32
# File 'lib/generators/delayed_job/delayed_job_generator.rb', line 28

def create_migration_file
  if defined?(ActiveRecord)
    migration_template 'migration.rb', 'db/migrate/create_delayed_jobs.rb'
  end
end

- (Object) create_script_file



23
24
25
26
# File 'lib/generators/delayed_job/delayed_job_generator.rb', line 23

def create_script_file
  template 'script', 'script/delayed_job'
  chmod 'script/delayed_job', 0755
end