Class: ShopifyApp::Generators::AddAfterAuthenticateJobGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_after_authenticate_jobObject



36
37
38
# File 'lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb', line 36

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

#init_after_authenticate_configObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb', line 14

def init_after_authenticate_config
  initializer = load_initializer

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

  inject_into_file(
    "config/initializers/shopify_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