Class: ShopQiAppWebhookGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ShopQiAppWebhookGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_routes ⇒ Object
- #copy_files ⇒ Object
- #install_migration ⇒ Object
- #show ⇒ Object
- #update_files ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
32 33 34 |
# File 'lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb', line 32 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#add_routes ⇒ Object
14 15 16 |
# File 'lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb', line 14 def add_routes route "use_shopqi_webhook" end |
#copy_files ⇒ Object
8 9 10 11 12 |
# File 'lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb', line 8 def copy_files directory 'app' directory 'script' chmod "script/delayed_job", 0755 end |
#install_migration ⇒ Object
23 24 25 26 |
# File 'lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb', line 23 def install_migration migration_template 'db/migrate/create_delayed_jobs.rb', 'db/migrate/create_delayed_jobs.rb' migration_template 'db/migrate/create_orders.rb', 'db/migrate/create_orders.rb' end |
#show ⇒ Object
28 29 30 |
# File 'lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb', line 28 def show readme "README" end |
#update_files ⇒ Object
18 19 20 21 |
# File 'lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb', line 18 def update_files prepend_to_file "app/models/shop.rb", "require \"\#{ShopQiAppWebhook::Engine.models_dir}/shop\"\n" insert_into_file "app/models/shop.rb", "\s\shas_many :orders\n", after: /class Shop( < ActiveRecord::Base){0,1}\n/ end |