MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / FromString

Method FromString

types/account.go:120–142  ·  view source on GitHub ↗

FromString converts string to UserPermissionRole.

(perm string)

Source from the content-addressed store, hash-verified

118
119// FromString converts string to UserPermissionRole.
120func (r *UserPermissionRole) FromString(perm string) {
121 if perm == "Void" {
122 *r = Void
123 return
124 } else if perm == "Admin" {
125 *r = Admin
126 return
127 }
128
129 *r = Void
130
131 for _, p := range strings.Split(perm, ",") {
132 p = strings.TrimSpace(p)
133 switch p {
134 case "Read":
135 *r |= Read
136 case "Write":
137 *r |= Write
138 case "Super":
139 *r |= Super
140 }
141 }
142}
143
144// UserPermissionFromRole construct a new user permission instance from primitive user permission role enum.
145func UserPermissionFromRole(role UserPermissionRole) *UserPermission {

Callers 3

UnmarshalJSONMethod · 0.95
runGrantFunction · 0.80

Calls

no outgoing calls

Tested by 1