Class: ApprovalEngine::Delegation

Inherits:
ApplicationRecord show all
Defined in:
app/models/approval_engine/delegation.rb

Overview

A time-bound proxy lease: while it is active, the delegatee may act on steps assigned to the delegator (e.g. covering approvals during a vacation). The ledger still records the delegator as the intended actor and the delegatee as the actual actor, so the proxy is always visible in the audit trail.

Class Method Summary collapse

Class Method Details

.active_for(delegator, tenant_id: nil, at: Time.current) ⇒ Object

Active delegations from a given delegator, optionally tenant-scoped.



20
21
22
23
# File 'app/models/approval_engine/delegation.rb', line 20

def self.active_for(delegator, tenant_id: nil, at: Time.current)
  scope = in_effect(at).where(delegator: delegator)
  tenant_id ? scope.for_tenant(tenant_id) : scope
end