SubjectToString converts a Subject object to string format.
(subject *base.Subject)
| 71 | |
| 72 | // SubjectToString converts a Subject object to string format. |
| 73 | func SubjectToString(subject *base.Subject) string { |
| 74 | // Convert the subject's type and id to a string in the format of an entity |
| 75 | entity := fmt.Sprintf(ENTITY, subject.GetType(), subject.GetId()) |
| 76 | |
| 77 | // If the subject is a user, return the entity string |
| 78 | if IsDirectSubject(subject) { |
| 79 | return entity |
| 80 | } |
| 81 | |
| 82 | // If the subject is not a user, add the relation to the string |
| 83 | return fmt.Sprintf("%s"+RELATION, entity, subject.GetRelation()) |
| 84 | } |
| 85 | |
| 86 | // ToString function converts a Tuple object to a string format. |
| 87 | func ToString(tup *base.Tuple) string { |
no test coverage detected