Class: AuthAssist::RoleMigrations::MultiRoleAssignment

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/role_migrations.rb

Instance Attribute Summary

Attributes inherited from Base

#generator

Instance Method Summary collapse

Methods inherited from Base

#generate_reverse_migration, #initialize, #setup

Methods included from MigrationHelper

#copy_migration, #file_reverse, #find_migration, included, #migration, #migration_dir, #migration_exists?, #reverse_migration_methods

Methods included from MigrationHelper::CodeRefactor

#clear_user_relations, #erase_in_user, #has_role_assignments, #has_roles, #has_roles_through_assignments, #insert_user_relation, #remove_user_relation, #role_assignment_file_content, #role_file_content, #write_model_file

Constructor Details

This class inherits a constructor from AuthAssist::RoleMigrations::Base

Instance Method Details

#configureObject



145
146
147
148
149
150
151
# File 'lib/generators/role_migrations.rb', line 145

def configure      
  insert_user_relation(has_role_assignments)
  insert_user_relation(has_roles_through_assignments)

  generate_role_model
  generate_role_assignment_model      
end

#migration_namesObject



135
136
137
# File 'lib/generators/role_migrations.rb', line 135

def migration_names
  ['add_role_assignment_id_to_user', 'create_role_assignments', 'create_roles']
end

#reverse_configureObject



153
154
155
156
157
158
159
# File 'lib/generators/role_migrations.rb', line 153

def reverse_configure
  remove_role_model
  remove_role_assignment_model

  remove_user_relation(has_role_assignments)
  remove_user_relation(has_roles_through_assignments)
end

#reverse_migrationObject



161
162
163
# File 'lib/generators/role_migrations.rb', line 161

def reverse_migration      
  migration_template 'remove_multi_role_assignments_migration.rb', 'remove_multi_role_assignments'
end

#run_migrationObject



139
140
141
142
143
# File 'lib/generators/role_migrations.rb', line 139

def run_migration        
  migration 'add_role_assignment_id_to_user role_assignment_id:integer'
  migration 'create_role_assignments role_id:integer user_id:integer'      
  migration 'create_roles name:string'
end