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


28
29
30
# File 'lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb', line 28

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
# File 'lib/generators/shopify_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: 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_authneticate_job to config. Add this line manually: #{after_authenticate_job_config}", :red
  end
end