Class: AsyncTask::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



13
14
15
# File 'lib/generators/async_task/install_generator.rb', line 13

def self.next_migration_number(dirname)
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#create_async_task_filesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/async_task/install_generator.rb', line 21

def create_async_task_files
  template 'async_task_attempt.rb.erb', 'app/models/async_task/attempt.rb'
  template 'async_task_attempt_job.rb.erb', 'app/jobs/async_task/attempt_job.rb'
  template 'async_task_attempt_batch_job.rb.erb', 'app/jobs/async_task/attempt_batch_job.rb'

  if defined?(RSpec)
    template 'async_task_attempt_spec.rb.erb', 'spec/models/async_task/attempt_spec.rb'
    template 'async_task_attempt_job_spec.rb.erb', 'spec/jobs/async_task/attempt_job_spec.rb'
    template 'async_task_attempt_batch_job_spec.rb.erb', 'spec/jobs/async_task/attempt_batch_job_spec.rb'
  end

  if defined?(FactoryBot) || defined?(FactoryGirl)
    template 'async_task_attempts.rb.erb', 'spec/factories/async_task/attempts.rb'
  end
end

#create_migration_fileObject



17
18
19
# File 'lib/generators/async_task/install_generator.rb', line 17

def create_migration_file
  migration_template 'create_async_task_attempts.rb', 'db/migrate/create_async_task_attempts.rb'
end