Class: PermissionGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/permission/permission_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_abilityObject



44
45
46
# File 'lib/generators/permission/permission_generator.rb', line 44

def copy_ability
	copy_file "ability_model.rb","app/models/ability.rb"
end

#copy_module_action_migrationObject



16
17
18
19
20
21
22
# File 'lib/generators/permission/permission_generator.rb', line 16

def copy_module_action_migration
	if (behavior == :invoke && model_exists?("module_action")) || (behavior == :revoke && role_migration_exists?)
    migration_template "module_action_migration_existing.rb", "db/migrate/add_name_to_module_action.rb", migration_version: migration_version
  else
    migration_template "module_action_migration.rb", "db/migrate/create_module_action.rb", migration_version: migration_version
  end
end

#copy_module_action_modelObject



32
33
34
# File 'lib/generators/permission/permission_generator.rb', line 32

def copy_module_action_model
  copy_file "module_action_model.rb","app/models/module_action.rb"
end

#copy_module_group_migrationObject



8
9
10
11
12
13
14
# File 'lib/generators/permission/permission_generator.rb', line 8

def copy_module_group_migration
	if (behavior == :invoke && model_exists?("module_group")) || (behavior == :revoke && role_migration_exists?)
    migration_template "module_group_migration_existing.rb", "db/migrate/add_name_to_module_group.rb", migration_version: migration_version
  else
    migration_template "module_group_migration.rb", "db/migrate/create_module_group.rb", migration_version: migration_version
  end
end

#copy_module_group_modelObject



36
37
38
# File 'lib/generators/permission/permission_generator.rb', line 36

def copy_module_group_model
  copy_file "module_group_model.rb","app/models/module_group.rb"
end

#copy_module_permission_migrationObject



24
25
26
27
28
29
30
# File 'lib/generators/permission/permission_generator.rb', line 24

def copy_module_permission_migration
	if (behavior == :invoke && model_exists?("module_permission")) || (behavior == :revoke && role_migration_exists?)
    migration_template "module_permission_migration_existing.rb", "db/migrate/add_group_action_to_module_permission.rb", migration_version: migration_version
  else
    migration_template "module_permission_migration.rb", "db/migrate/create_module_permission.rb", migration_version: migration_version
  end
end

#copy_module_permission_modelObject



40
41
42
# File 'lib/generators/permission/permission_generator.rb', line 40

def copy_module_permission_model
  copy_file "module_permission_model.rb","app/models/module_permission.rb"
end