Class: DuodealerApp::Generators::AddWebhookGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DuodealerApp::Generators::AddWebhookGenerator
- Defined in:
- lib/generators/duodealer_app/add_webhook/add_webhook_generator.rb
Instance Method Summary collapse
- #add_webhook_job ⇒ Object
- #init_webhook_config ⇒ Object
- #inject_webhook_to_duodealer_app_initializer ⇒ Object
Instance Method Details
#add_webhook_job ⇒ Object
39 40 41 42 43 |
# File 'lib/generators/duodealer_app/add_webhook/add_webhook_generator.rb', line 39 def add_webhook_job @job_file_name = job_file_name + "_job" @job_class_name = @job_file_name.classify template "webhook_job.rb", "app/jobs/#{@job_file_name}.rb" end |
#init_webhook_config ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/duodealer_app/add_webhook/add_webhook_generator.rb', line 14 def init_webhook_config initializer = load_initializer return if initializer.include?("config.webhooks") inject_into_file( "config/initializers/duodealer_app.rb", " config.webhooks = [\n ]\n", before: "end" ) end |
#inject_webhook_to_duodealer_app_initializer ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/duodealer_app/add_webhook/add_webhook_generator.rb', line 25 def inject_webhook_to_duodealer_app_initializer inject_into_file( "config/initializers/duodealer_app.rb", webhook_config, after: "config.webhooks = [" ) initializer = load_initializer unless initializer.include?(webhook_config) shell.say "Error adding webhook to config. Add this line manually: #{webhook_config}", :red end end |