Integrate policy-aware item scopes
This commit is contained in:
@@ -59,6 +59,26 @@ func (policy *collectionPolicy) setRecordPolicy(record collectionRecordPolicy) {
|
||||
policy.recordPolicies[record.owner] = cloneCollectionPolicyScope(record.scope)
|
||||
}
|
||||
|
||||
func (policy *collectionPolicy) setRecordPolicyAt(index int, record collectionRecordPolicy) {
|
||||
if index < 0 {
|
||||
return
|
||||
}
|
||||
if record.owner == nil {
|
||||
record.owner = newCollectionRecordPolicy().owner
|
||||
}
|
||||
if policy.recordPolicies == nil {
|
||||
policy.recordPolicies = make(map[*collectionRecordOwner]collectionPolicyScope)
|
||||
}
|
||||
for len(policy.recordOrder) <= index {
|
||||
owner := newCollectionRecordPolicy().owner
|
||||
policy.recordOrder = append(policy.recordOrder, owner)
|
||||
policy.recordPolicies[owner] = collectionPolicyScope{}
|
||||
}
|
||||
delete(policy.recordPolicies, policy.recordOrder[index])
|
||||
policy.recordOrder[index] = record.owner
|
||||
policy.recordPolicies[record.owner] = cloneCollectionPolicyScope(record.scope)
|
||||
}
|
||||
|
||||
func (policy collectionPolicy) recordPolicyAt(index int) (collectionRecordPolicy, bool) {
|
||||
if index < 0 || index >= len(policy.recordOrder) {
|
||||
return collectionRecordPolicy{}, false
|
||||
|
||||
Reference in New Issue
Block a user