Module: Conjur::Policy::Doc
- Defined in:
- lib/conjur/policy/doc.rb
Defined Under Namespace
Classes: Attribute, Operation
Class Method Summary
collapse
Class Method Details
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
35
36
37
38
39
|
# File 'lib/conjur/policy/doc.rb', line 9
def list
all_types = Set.new
new_types = Set.new
new_types += Conjur::Policy::Types::Base.subclasses
all_types += new_types
while !new_types.empty?
iteration_new_types = Set.new
new_types.each do |type|
subtypes = type.subclasses
iteration_new_types += (Set.new(subtypes) - all_types)
all_types += subtypes
end
new_types = iteration_new_types.dup
iteration_new_types.clear
end
all_types.map do |type|
next if type == Conjur::Policy::Ruby::Policy
description = type.send(:description) rescue ""
example = type.send(:example) rescue ""
attributes = type.fields.map do |id, kind|
Attribute.new(id, kind)
end
unless attributes.empty?
super_id = type.superclass.short_name rescue nil
super_id = nil if super_id == "Base"
Operation.new(type.short_name, super_id, description, example, attributes)
end
end.compact.sort{|a,b| a.id <=> b.id}
end
|