Class: Rerout::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rerout/install_generator.rb

Overview

‘rails generate rerout:install`

Drops a ‘config/initializers/rerout.rb` initializer and appends the webhook route to `config/routes.rb` so a fresh app is wired up in one command.

Instance Method Summary collapse

Instance Method Details

#add_webhook_routevoid

This method returns an undefined value.

Append the webhook receiver route to ‘config/routes.rb`.



28
29
30
31
32
# File 'lib/generators/rerout/install_generator.rb', line 28

def add_webhook_route
  route_line = "post '/rerout/webhooks', " \
               "to: 'rerout/rails/webhook#receive', as: :rerout_webhook"
  route(route_line)
end

#create_initializervoid

This method returns an undefined value.

Copy the commented initializer into the host application.



21
22
23
# File 'lib/generators/rerout/install_generator.rb', line 21

def create_initializer
  template 'rerout.rb', 'config/initializers/rerout.rb'
end

#print_post_installvoid

This method returns an undefined value.

Print next steps.



37
38
39
# File 'lib/generators/rerout/install_generator.rb', line 37

def print_post_install
  readme 'POST_INSTALL' if behavior == :invoke
end