Sha256: ecc02671c5eef7b1b95fc2a729dcaa679ab931cb6c25237dc6123494135db3a0

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'

module Rbacan
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../../install/templates', __FILE__)
      desc "Add the migrations for roles and permissions"

      def self.next_migration_number(path)
        next_migration_number = current_migration_number(path) + 1
        ActiveRecord::Migration.next_migration_number(next_migration_number)
      end

      def copy_migrations
        migration_template "create_permissions.rb", "db/migrate/create_permissions.rb"
        migration_template "create_roles.rb", "db/migrate/create_roles.rb"
        migration_template "create_role_permissions.rb", "db/migrate/create_role_permissions.rb"
        migration_template "create_user_roles.rb", "db/migrate/create_user_roles.rb"
      end

      def copy_seed
        copy_file 'copy_to_seeds.rb', "db/copy_to_seeds.rb"
      end

      def copy_initializer
        copy_file 'rbacan.rb', 'config/initializers/rbacan.rb'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rbacan-0.1.2 lib/generators/rbacan/install_generator.rb
rbacan-0.1.1 lib/generators/rbacan/install_generator.rb