Module: Rbacan::RolesAndPermissions

Defined in:
lib/rbacan/roles_and_permissions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#test_methodObject (readonly)

Returns the value of attribute test_method.



4
5
6
# File 'lib/rbacan/roles_and_permissions.rb', line 4

def test_method
  @test_method
end

Class Method Details

.assign_permissions_to_role(role_name, permissions) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rbacan/roles_and_permissions.rb', line 18

def self.assign_permissions_to_role(role_name, permissions)
    chosen_role = Rbacan::Role.find_by_name(role_name)
    permissions.each do |permission|
        given_permission = Rbacan::Permission.find_by_name(permission)
        Rbacan::RolePermission.create(role_id: chosen_role.id, permission_id: given_permission.id)
    end
end

.create_permissions(permissions) ⇒ Object



12
13
14
15
16
# File 'lib/rbacan/roles_and_permissions.rb', line 12

def self.create_permissions(permissions)
    permissions.each do |permission|
        Rbacan::Permission.create(name: permission)
    end
end

.create_roles(roles) ⇒ Object



6
7
8
9
10
# File 'lib/rbacan/roles_and_permissions.rb', line 6

def self.create_roles(roles)
    roles.each do |role|
        Rbacan::Role.create(name: role)
    end
end