Class: BankTeller::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Extended by:
ActiveRecord::Generators::Migration
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/bank_teller/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_numberObject



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

def self.next_migration_number(*)
  sleep 1 # Prevents Duplicate Timestamps on FAAAAST Machines
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#alter_usersObject



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

def alter_users
  if ActiveRecord::Base.connection.table_exists?('users')
    migration_template "add_bank_teller_fields_to_users.rb", "db/migrate/add_bank_teller_fields_to_users.rb"
  else
    raise "You must have a users table to install Bank Teller."
  end
end

#create_subscriptionsObject



27
28
29
# File 'lib/generators/bank_teller/install_generator.rb', line 27

def create_subscriptions
  migration_template "create_subscriptions.rb", "db/migrate/create_subscriptions.rb"
end