Class: Paysto::ModelsGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Migration timestamp.



10
11
12
13
14
15
16
# File 'lib/generators/paysto/models_generator.rb', line 10

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#copy_modelsObject

Render configured models.



24
25
26
27
28
# File 'lib/generators/paysto/models_generator.rb', line 24

def copy_models
  template 'models/payment.rb',              "app/models/#{Paysto.payment_class_name.underscore}.rb"
  template 'models/invoice.rb',              "app/models/#{Paysto.invoice_class_name.underscore}.rb"
  template 'models/invoice_notification.rb', "app/models/#{Paysto.invoice_notification_class_name.underscore}.rb"
end

#create_migration_fileObject

Create migration with required tables.



19
20
21
# File 'lib/generators/paysto/models_generator.rb', line 19

def create_migration_file
  migration_template 'migration.rb', 'db/migrate/create_paysto_tables.rb'
end