Class: Yes::Auth::Generators::Principals::UserRoleGenerator
- Inherits:
-
BaseGenerator
- Object
- Rails::Generators::Base
- BaseGenerator
- Yes::Auth::Generators::Principals::UserRoleGenerator
show all
- Defined in:
- lib/yes/auth/generators/principals/user_role_generator.rb
Overview
Generates the migration for the user-role join table
This generator creates a join table for the HABTM association between User and Role principals, with UUID foreign keys and cascade deletes.
Instance Method Summary
collapse
#_destination, #_migration_dir, #create, next_migration_number
Instance Method Details
#_migration_file_name ⇒ Object
27
28
29
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 27
def _migration_file_name
"create_join_table_#{_user_table_name.singularize}_#{_role_table_name.singularize}.rb"
end
|
#_role_primary_key ⇒ Object
43
44
45
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 43
def _role_primary_key
Yes::Auth::Principals::User.reflect_on_association(:roles).foreign_key
end
|
#_role_table_name ⇒ Object
35
36
37
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 35
def _role_table_name
Yes::Auth::Principals::Role.table_name
end
|
#_source_template ⇒ Object
47
48
49
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 47
def _source_template
'user_role.erb'
end
|
#_table_name ⇒ Object
22
23
24
25
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 22
def _table_name
"#{Yes::Auth::Principals::User.reflect_on_association(:roles).table_name}_" \
"#{Yes::Auth::Principals::Role.reflect_on_association(:users).plural_name}"
end
|
#_user_primary_key ⇒ Object
39
40
41
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 39
def _user_primary_key
Yes::Auth::Principals::Role.reflect_on_association(:users).foreign_key
end
|
#_user_table_name ⇒ Object
31
32
33
|
# File 'lib/yes/auth/generators/principals/user_role_generator.rb', line 31
def _user_table_name
Yes::Auth::Principals::User.table_name
end
|