Class: Paysto::ModelsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Paysto::ModelsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/paysto/models_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Migration timestamp.
Instance Method Summary collapse
-
#copy_models ⇒ Object
Render configured models.
-
#create_migration_file ⇒ Object
Create migration with required tables.
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. Time.new.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#copy_models ⇒ Object
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_file ⇒ Object
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 |