class TradoGooglemerchantModule::Generators::InstallGenerator
Public Instance Methods
assign_model_concerns()
click to toggle source
# File lib/generators/trado_googlemerchant_module/install_generator.rb, line 21 def assign_model_concerns googlemerchant_content = <<-CONTENT has_googlemerchant CONTENT inject_into_file "app/models/product.rb", googlemerchant_content, after: "class Product < ActiveRecord::Base" end
copy_migration()
click to toggle source
# File lib/generators/trado_googlemerchant_module/install_generator.rb, line 6 def copy_migration unless googlemerchant_migration_already_exists? timestamp_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i copy_file "migration.rb", "db/migrate/#{timestamp_number}_add_googlemerchant_attributes.rb" end end
setup_routes()
click to toggle source
# File lib/generators/trado_googlemerchant_module/install_generator.rb, line 13 def setup_routes route_content = <<-CONTENT mount TradoGooglemerchantModule::Engine => '/google_merchant' CONTENT inject_into_file "config/routes.rb", route_content, after: "Trado::Application.routes.draw do" end
Private Instance Methods
googlemerchant_migration_already_exists?()
click to toggle source
# File lib/generators/trado_googlemerchant_module/install_generator.rb, line 32 def googlemerchant_migration_already_exists? Dir.glob("#{File.join(destination_root, File.join("db", "migrate"))}/[0-9]*_*.rb").grep(/\d+_add_googlemerchant_attributes.rb$/).first end