blob: 78d0ba0c27f01022a6d8d5ec2985cd364127613c (
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
|
module ComplianceControlsHelper
def subclass_selection_list
ComplianceControl.subclass_patterns.map(&method(:make_subclass_selection_item))
end
def make_subclass_selection_item(key_pattern)
key, pattern = key_pattern
[t("compliance_controls.filters.subclasses.#{key}"), "-#{pattern}-"]
end
def display_control_attribute(key, value)
if key == "target"
parts = value.match(%r((?'object_type'\w+)#(?'attribute'\w+)))
object_type = ComplianceControl.tmf("subclasses.#{parts[:object_type]}")
target = I18n.t("activerecord.attributes.#{parts[:object_type]}.#{parts[:attribute]}")
"#{object_type} - #{target}"
else
value
end
end
def compliance_control_metadatas(compliance_control)
attributes = resource.class.dynamic_attributes
attributes.push(*resource.control_attributes.keys) if resource&.control_attributes&.keys
{}.tap do |hash|
attributes.each do |attribute|
hash[ComplianceControl.human_attribute_name(attribute)] = display_control_attribute(attribute, resource.send(attribute))
end
end
end
end
|