Sha256: 7f423cd9381b3009822826b36d3f56097045d5d6f743a0ba3bd84235d923a278

Contents?: true

Size: 979 Bytes

Versions: 3

Compression:

Stored size: 979 Bytes

Contents

class Recipes::DelayedJob < Rails::AppBuilder
  def ask
    use_delayed_job = answer(:"delayed-job") { Ask.confirm("Do you want to use delayed jobs?") }
    set(:delayed_job, use_delayed_job)
  end

  def create
    add_delayed_job if selected?(:delayed_job)
  end

  def install
    heroku = load_recipe(:heroku)
    set(:heroku, heroku.installed?)
    add_delayed_job
  end

  def installed?
    gem_exists?(/delayed_job_active_record/)
  end

  private

  def add_delayed_job
    gather_gem "delayed_job_active_record"

    delayed_job_config = "config.active_job.queue_adapter = :delayed_job"
    application(delayed_job_config)

    after(:gem_install) do
      generate "delayed_job:active_record"
      run "bundle binstubs delayed_job"
      add_readme_section :internal_dependencies, :delayed_job

      if selected?(:heroku)
        gsub_file "Procfile", /^.*$/m do |match|
          "#{match}worker: bundle exec rake jobs:work"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
potassium-2.2.0 lib/potassium/recipes/delayed_job.rb
potassium-2.1.0 lib/potassium/recipes/delayed_job.rb
potassium-2.0.0 lib/potassium/recipes/delayed_job.rb