Class: Payflow::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(_dirname) ⇒ Object



35
36
37
# File 'lib/generators/payflow/install_generator.rb', line 35

def self.next_migration_number(_dirname)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_initializerObject



15
16
17
# File 'lib/generators/payflow/install_generator.rb', line 15

def create_initializer
  template "initializer.rb", "config/initializers/payflow.rb"
end

#create_migrationsObject



19
20
21
22
23
# File 'lib/generators/payflow/install_generator.rb', line 19

def create_migrations
  migration_template "migration_subscription.rb", "db/migrate/create_payflow_subscriptions.rb"
  migration_template "migration_invoice.rb", "db/migrate/create_payflow_invoices.rb"
  migration_template "migration_webhook_event.rb", "db/migrate/create_payflow_webhook_events.rb"
end

#show_readmeObject



25
26
27
28
29
30
31
32
33
# File 'lib/generators/payflow/install_generator.rb', line 25

def show_readme
  return unless behavior == :invoke

  say "\nPayflow installed successfully!", :green
  say "  Run `rails db:migrate` to apply the migrations."
  say ""
  say "Note: Payflow::Engine also appends engine migrations when the gem is loaded."
  say "Use either this generator OR `rails payflow:install:migrations` — not both."
end