Class: DuodealerApp::Generators::AddAfterAuthenticateJobGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/duodealer_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_after_authenticate_jobObject



30
31
32
# File 'lib/generators/duodealer_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb', line 30

def add_after_authenticate_job
  template "after_authenticate_job.rb", "app/jobs/#{job_file_name}_job.rb"
end

#init_after_authenticate_configObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/duodealer_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb', line 12

def init_after_authenticate_config
  initializer = load_initializer

  after_authenticate_job_config =
    "  config.after_authenticate_job = "\
    "{ job: \"Duodealer::AfterAuthenticateJob\", inline: false }\n"

  inject_into_file(
    "config/initializers/duodealer_app.rb",
    after_authenticate_job_config,
    before: "end"
  )

  unless initializer.include?(after_authenticate_job_config)
    shell.say("Error adding after_authenticate_job to config. Add this line manually: #{after_authenticate_job_config}", :red)
  end
end