Class: AuthAssist::RoleMigrations::RoleAssignment

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



119
120
121
122
# File 'lib/generators/role_migrations.rb', line 119

def configure
  generate_role_model
  insert_user_relation(has_roles)
end

#migration_namesObject



110
111
112
# File 'lib/generators/role_migrations.rb', line 110

def migration_names
  ['add_role_id_to_user', 'create_roles']
end

#reverse_configureObject



124
125
126
127
# File 'lib/generators/role_migrations.rb', line 124

def reverse_configure
  remove_role_model
  remove_user_relation(has_roles)
end

#reverse_migrationObject



129
130
131
# File 'lib/generators/role_migrations.rb', line 129

def reverse_migration      
  migration_template 'remove_role_assignments_migration.rb', 'remove_role_assignments'
end

#run_migrationObject



114
115
116
117
# File 'lib/generators/role_migrations.rb', line 114

def run_migration
  migration 'add_role_id_to_user role_id:integer'
  migration 'create_roles name:string'
end