Class: Cancannible::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Cancannible::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/cancannible/install_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
while methods have moved around this has been the implementation since ActiveRecord 3.0.
Instance Method Summary collapse
- #create_initializer_file ⇒ Object
- #create_permission_migration_file ⇒ Object
- #create_permission_model_file ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
while methods have moved around this has been the implementation since ActiveRecord 3.0
28 29 30 31 32 33 34 35 |
# File 'lib/generators/cancannible/install_generator.rb', line 28 def self.next_migration_number(dirname) 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_initializer_file ⇒ Object
14 15 16 |
# File 'lib/generators/cancannible/install_generator.rb', line 14 def create_initializer_file template 'cancannible_initializer.rb', 'config/initializers/cancannible.rb' end |
#create_permission_migration_file ⇒ Object
18 19 20 |
# File 'lib/generators/cancannible/install_generator.rb', line 18 def migration_template 'migration.rb', 'db/migrate/create_cancannible_permissions.rb' end |
#create_permission_model_file ⇒ Object
22 23 24 |
# File 'lib/generators/cancannible/install_generator.rb', line 22 def template 'permission.rb', 'app/models/permission.rb' end |