Class: TradoStripeModule::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#assign_model_concernsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/trado_stripe_module/install_generator.rb', line 17

def assign_model_concerns
	order_content = <<-CONTENT

	has_order_stripe
	CONTENT
	transaction_content = <<-CONTENT

	has_transaction_stripe
	CONTENT

	store_setting_content = <<-CONTENT

	has_store_setting_stripe
	CONTENT

	inject_into_file "app/models/order.rb", order_content, after: "class Order < ActiveRecord::Base"
	inject_into_file "app/models/transaction.rb", transaction_content, after: "class Transaction < ActiveRecord::Base"
	inject_into_file "app/models/store_setting.rb", store_setting_content, after: "class StoreSetting < ActiveRecord::Base"
end

#copy_controllerObject



13
14
15
# File 'lib/generators/trado_stripe_module/install_generator.rb', line 13

def copy_controller
	template "controller.rb", "app/controllers/carts/stripe_controller.rb"
end

#copy_migrationObject



6
7
8
9
10
11
# File 'lib/generators/trado_stripe_module/install_generator.rb', line 6

def copy_migration
	unless stripe_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_stripe_attributes.rb"
	end
end