Class: SpreeRazorpayCheckout::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SpreeRazorpayCheckout::Generators::InstallGenerator
- Defined in:
- lib/generators/spree_razorpay_checkout/install/install_generator.rb
Instance Method Summary collapse
- #add_javascripts ⇒ Object
- #add_migrations ⇒ Object
- #add_razorpay_widget_block ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#add_javascripts ⇒ Object
7 8 9 10 |
# File 'lib/generators/spree_razorpay_checkout/install/install_generator.rb', line 7 def add_javascripts # append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_razorpay_checkout\n" # append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/process_razorpay\n" end |
#add_migrations ⇒ Object
12 13 14 |
# File 'lib/generators/spree_razorpay_checkout/install/install_generator.rb', line 12 def add_migrations run 'bin/rails railties:install:migrations FROM=spree_razorpay_checkout' end |
#add_razorpay_widget_block ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/spree_razorpay_checkout/install/install_generator.rb', line 24 def say_status :spree_razorpay_checkout, "Adding Razorpay Affordability widget to Product Details", :green require Rails.root.join("config/environment") ::Spree::PageSection .where(type: "Spree::PageSections::ProductDetails") .find_each do |section| next if section.blocks.exists?( type: "Spree::PageBlocks::Products::RazorpayAffordability" ) section.blocks.create!( type: "Spree::PageBlocks::Products::RazorpayAffordability", position: section.blocks.maximum(:position).to_i + 1 ) say_status :created, "Added Razorpay block to section #{section.name}", :green end end |
#run_migrations ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/generators/spree_razorpay_checkout/install/install_generator.rb', line 16 def run_migrations if [:migrate] run 'bin/rails db:migrate' else say_status :skip, "Skipped running migrations. You can run them later with `bin/rails db:migrate`.", :yellow end end |