class ActiveRecord::Generators::MerchantGenerator
Public Instance Methods
copy_pay_merchant_migration()
click to toggle source
# File lib/generators/active_record/merchant_generator.rb, line 12 def copy_pay_merchant_migration if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name)) migration_template "merchant_migration.rb", "#{migration_path}/add_pay_merchant_to_#{table_name}.rb", migration_version: migration_version else say "#{model_path} does not exist.", :red say "⚠️ Make sure the #{name} model exists before running this generator." end end
inject_pay_merchant_content()
click to toggle source
If the file already contains the contents, the user will receive this warning:
File unchanged! The supplied flag value not found!
This can be ignored as it just means the contents already exist and the file is unchanged. Thor will be updated to improve this message: github.com/rails/thor/issues/706
# File lib/generators/active_record/merchant_generator.rb, line 27 def inject_pay_merchant_content return unless model_exists? content = model_contents class_path = (namespaced? ? class_name.to_s.split("::") : [class_name]) indent_depth = class_path.size - 1 content = content.split("\n").map { |line| " " * indent_depth + line }.join("\n") << "\n" inject_into_class(model_path, class_path.last, content) end
Private Instance Methods
model_contents()
click to toggle source
# File lib/generators/active_record/merchant_generator.rb, line 39 def model_contents " include Pay::Merchant" end