blob: 0a2c45f1289fcbc71a94f20b81097135847c3575 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
class Ability
def self.allowed(object, subject)
case subject.class.name
when "Project" then project_abilities(object, subject)
else []
end
end
def self.project_abilities(user, project)
rules = []
rules << [
:read_project,
:read_issue,
:read_team_member,
:read_note
] if project.readers.include?(user)
rules << [
:write_project,
:write_issue,
:write_note
] if project.writers.include?(user)
rules << [
:admin_project,
:admin_issue,
:admin_team_member,
:admin_note
] if project.admins.include?(user)
rules.flatten
end
end
|