Class: CapableGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CapableGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/capable/capable_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
10 11 12 13 14 15 16 17 |
# File 'lib/generators/capable/capable_generator.rb', line 10 def self.next_migration_number(dirname) #:nodoc: next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
Instance Method Details
#create_capable_migration ⇒ Object
19 20 21 |
# File 'lib/generators/capable/capable_generator.rb', line 19 def create_capable_migration migration_template 'migration.rb', File.join('db', 'migrate', 'capable_migration.rb') end |
#move_ability_model ⇒ Object
23 24 25 |
# File 'lib/generators/capable/capable_generator.rb', line 23 def move_ability_model template 'ability.rb', File.join('app', 'models', 'ability.rb') end |
#move_capability_model ⇒ Object
27 28 29 |
# File 'lib/generators/capable/capable_generator.rb', line 27 def move_capability_model template 'capability.rb', File.join('app', 'models', 'capability.rb') end |