Class: Entitlements::Extras::Orgchart::Rules::DirectReport
Constant Summary
collapse
- C =
::Contracts
Class Method Summary
collapse
common, extended, included
Class Method Details
.matches(value:, filename: nil, options: {}) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/entitlements/extras/orgchart/rules/direct_report.rb', line 24
def self.matches(value:, filename: nil, options: {})
manager_uid = value.downcase
begin
manager = Entitlements.cache[:people_obj].read(manager_uid)
rescue Entitlements::Data::People::NoSuchPersonError
Entitlements.logger.fatal "Manager #{manager_uid} does not exist for file #{filename}!"
raise "Manager #{manager_uid} does not exist!"
end
Entitlements.cache[:management_obj] ||= begin
Entitlements::Extras::Orgchart::Logic.new(people: Entitlements.cache.fetch(:people_obj).read)
end
if Entitlements.cache[:management_obj].direct_reports(manager).empty?
Entitlements.logger.fatal "Manager #{manager_uid} has no reports for file #{filename}!"
raise "Manager #{manager_uid} has no reports!"
end
result = Set.new([manager])
result.merge Entitlements.cache[:management_obj].direct_reports(manager)
end
|