Class: ScimitarRbac::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/scimitar_rbac/install_generator.rb

Overview

Generates migrations, models, and controllers for RBAC SCIM resources.

Usage:

rails generate scimitar_rbac:install

Instance Method Summary collapse

Instance Method Details

#create_controller_filesObject



29
30
31
32
33
# File 'lib/generators/scimitar_rbac/install_generator.rb', line 29

def create_controller_files
  template "roles_controller.rb.erb",        "app/controllers/scim_v2/roles_controller.rb"
  template "entitlements_controller.rb.erb",  "app/controllers/scim_v2/entitlements_controller.rb"
  template "applications_controller.rb.erb",  "app/controllers/scim_v2/applications_controller.rb"
end

#create_migration_fileObject



19
20
21
# File 'lib/generators/scimitar_rbac/install_generator.rb', line 19

def create_migration_file
  migration_template "migration.rb.erb", "db/migrate/create_scimitar_rbac_tables.rb"
end

#create_model_filesObject



23
24
25
26
27
# File 'lib/generators/scimitar_rbac/install_generator.rb', line 23

def create_model_files
  template "role_model.rb.erb",        "app/models/rbac_role.rb"
  template "entitlement_model.rb.erb", "app/models/rbac_entitlement.rb"
  template "application_model.rb.erb", "app/models/rbac_application.rb"
end

#display_post_install_messageObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/scimitar_rbac/install_generator.rb', line 35

def display_post_install_message
  say ""
  say "SCIM RBAC resources have been generated!", :green
  say ""
  say "Next steps:"
  say "  1. Run migrations:  rails db:migrate"
  say "  2. Add routes to config/routes.rb:"
  say ""
  say "     namespace :scim_v2, path: 'scim/v2' do"
  say "       mount Scimitar::Engine, at: '/'"
  say "       Scimitar::Rbac::RouteHelper.mount_rbac_routes(self,"
  say "         roles_controller:        'scim_v2/roles',"
  say "         entitlements_controller: 'scim_v2/entitlements',"
  say "         applications_controller: 'scim_v2/applications'"
  say "       )"
  say "     end"
  say ""
end