Class: Stonepath::Generators::WorkitemModelGenerator
- Inherits:
-
Base
- Object
- Rails::Generators::NamedBase
- Base
- Stonepath::Generators::WorkitemModelGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/stonepath/workitem_model/workitem_model_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
26 27 28 29 30 31 32 |
# File 'lib/generators/stonepath/workitem_model/workitem_model_generator.rb', line 26 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#create_migration ⇒ Object
14 15 16 |
# File 'lib/generators/stonepath/workitem_model/workitem_model_generator.rb', line 14 def create_migration migration_template 'migration.rb', "db/migrate/create_#{file_name.pluralize}.rb" end |
#create_model_file ⇒ Object
10 11 12 |
# File 'lib/generators/stonepath/workitem_model/workitem_model_generator.rb', line 10 def create_model_file template('model.rb', "app/models/#{file_name}.rb") if valid_model_name?(file_name) end |