Class: Payfast::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Payfast::Generators::InstallGenerator
- Defined in:
- lib/generators/payfast/install_generator.rb
Instance Method Summary collapse
- #add_erb_tag ⇒ Object
- #configure_development ⇒ Object
- #create_config_file ⇒ Object
- #create_controller ⇒ Object
- #create_migration ⇒ Object
- #create_model ⇒ Object
- #create_view_helper ⇒ Object
- #create_views ⇒ Object
- #modify_routes ⇒ Object
Instance Method Details
#add_erb_tag ⇒ Object
41 42 43 44 45 46 |
# File 'lib/generators/payfast/install_generator.rb', line 41 def add_erb_tag # Append an ERB tag to the application.html.erb file insert_into_file "app/views/layouts/application.html.erb", before: "</head>" do "<%= payfast_script_tag %>" end end |
#configure_development ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/generators/payfast/install_generator.rb', line 48 def configure_development insert_into_file "config/environments/development.rb", before: /^end/ do <<-RUBY.strip_heredoc.indent(2) config.hosts << /[a-z0-9-]+\.ngrok-free\.app/ RUBY end end |
#create_config_file ⇒ Object
33 34 35 |
# File 'lib/generators/payfast/install_generator.rb', line 33 def create_config_file template "config.yml", "config/payfast.yml" end |
#create_controller ⇒ Object
15 16 17 |
# File 'lib/generators/payfast/install_generator.rb', line 15 def create_controller template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb") end |
#create_migration ⇒ Object
29 30 31 |
# File 'lib/generators/payfast/install_generator.rb', line 29 def create_migration template "migration.rb", "db/migrate/#{}_create_carts.rb" end |
#create_model ⇒ Object
37 38 39 |
# File 'lib/generators/payfast/install_generator.rb', line 37 def create_model template "model.rb", "app/models/cart.rb" end |
#create_view_helper ⇒ Object
25 26 27 |
# File 'lib/generators/payfast/install_generator.rb', line 25 def create_view_helper template "helper.rb", "app/helpers/carts_helper.rb" end |
#create_views ⇒ Object
19 20 21 22 23 |
# File 'lib/generators/payfast/install_generator.rb', line 19 def create_views actions.each do |action| template "#{action}.html.erb", File.join("app/views", controller_file_name, "#{action}.html.erb") end end |
#modify_routes ⇒ Object
8 9 10 11 12 13 |
# File 'lib/generators/payfast/install_generator.rb', line 8 def modify_routes insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do # Read and insert the contents of your routes template file File.read(File.join(__dir__, "templates", "routes.rb")) end end |