Class: AuthAssist::Generators::ConfigGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- AuthAssist::Generators::ConfigGenerator
show all
- Includes:
- MigrationHelper, RoleMigrations
- Defined in:
- lib/generators/auth_assist/config/config_generator.rb
Class Method Summary
collapse
Instance Method Summary
collapse
clazz
#copy_migration, #file_reverse, #find_migration, included, #migration, #migration_dir, #migration_exists?, #reverse_migration, #reverse_migration_methods
#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
Class Method Details
.banner ⇒ Object
62
63
64
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 62
def self.banner
"#{$0} auth_assist:config strategy [admin_field, role_field, roles_field, roles_mask, role_assignment, multi_role_assignment]"
end
|
.source_root ⇒ Object
20
21
22
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 20
def self.source_root
@source_root ||= File.expand_path("../../templates", __FILE__)
end
|
Instance Method Details
#copy_locale ⇒ Object
47
48
49
50
51
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 47
def copy_locale
locale_file = File.expand_path("../../../../../config/locales/en.yml", __FILE__)
puts locale_file
copy_file locale_file, "config/locales/auth_assist.en.yml"
end
|
#create_ability_model ⇒ Object
35
36
37
38
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 35
def create_ability_model
copy_file 'ability.rb', 'app/models/ability.rb'
copy_file 'permits.rb', 'lib/permits.rb'
end
|
#create_admin_user ⇒ Object
40
41
42
43
44
45
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 40
def create_admin_user
return if !options[:admin]
run 'rails g devise Admin' if options[:admin]
gsub_file 'app/models/admin.rb', /ActiveRecord::Base/, 'User'
end
|
#create_initializer ⇒ Object
30
31
32
33
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 30
def create_initializer
template "auth_assistant.rb", "config/initializers/x_auth_assistant.rb"
end
|
#init_devise ⇒ Object
24
25
26
27
28
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 24
def init_devise
return if !options[:devise]
run 'rails g devise_install'
run 'rails g devise User'
end
|
#run_migration ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/generators/auth_assist/config/config_generator.rb', line 53
def run_migration
clear_user_relations
return nil if !options[:migration]
clazz = AuthAssist::RoleMigrations.clazz(name)
mig_obj = clazz.new(self)
mig_obj.run_migration
mig_obj.configure
end
|