13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/grant-front/diagram.rb', line 13
def create
policies = []
GrantFront::Policy.all(@options).each do |policy|
if @options[:classes].nil? or @options[:classes].include?(policy.klass)
policies << GrantFront::Policy.find(policy.klass)
end
end
text = ''
policies.each do |policy|
text += "\n### #{policy.name}\n\n"
if policy.roles.count > 0
text += "||#{policy.roles.join('|')}|\n"
text += "|:-|#{policy.roles.map{':-:'}.join('|')}|\n"
policy.methods.keys.each do |method|
raw = "|#{method}|"
policy.roles.each do |role|
raw += 'o' if policy.methods[method].include?(role)
raw += '|'
end
text += "#{raw}\n"
end
else
text += "* no policy\n"
end
end
text
end
|