Class: HrLite::ApprovalFlow

Inherits:
ApplicationRecord show all
Includes:
Audited
Defined in:
app/models/hr_lite/approval_flow.rb

Overview

"Leave needs the manager, then HR." One active flow per subject type; a type with no flow keeps whatever single-decision behaviour it had.

Constant Summary

Constants included from Audited

HrLite::Audited::REDACTED, HrLite::Audited::SKIPPED_ATTRIBUTES

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.approvable_typesObject

Subject types that have opted in. Declared rather than derived so a flow cannot be pointed at a model that has no idea it is approvable.



22
23
24
25
26
27
# File 'app/models/hr_lite/approval_flow.rb', line 22

def self.approvable_types
  %w[
    HrLite::LeaveRequest HrLite::CompOffRequest
    HrLite::RegularizationRequest HrLite::Resignation HrLite::Expense
  ].freeze
end

.for(subject_type) ⇒ Object



16
17
18
# File 'app/models/hr_lite/approval_flow.rb', line 16

def self.for(subject_type)
  active.find_by(subject_type: subject_type.to_s)
end

Instance Method Details

#subject_labelObject



29
# File 'app/models/hr_lite/approval_flow.rb', line 29

def subject_label = subject_type.demodulize.underscore.humanize