Remap recomputes the name mappings from the inner attribute. Use this if the underlying attribute is modified after the mapped attribute has been initially created.
()
| 64 | // the underlying attribute is modified after the mapped attribute has been |
| 65 | // initially created. |
| 66 | func (ma *MappedAttributeExpr) Remap() { |
| 67 | var ( |
| 68 | n = &Object{} |
| 69 | o = AsObject(ma.Type) |
| 70 | ) |
| 71 | for _, nat := range *o { |
| 72 | elems := strings.Split(nat.Name, ":") |
| 73 | n.Set(elems[0], nat.Attribute) |
| 74 | if len(elems) > 1 { |
| 75 | ma.nameMap[elems[0]] = elems[1] |
| 76 | ma.reverseMap[elems[1]] = elems[0] |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // Conserve examples defined on user type |
| 81 | ma.UserExamples = ma.ExtractUserExamples() |
| 82 | |
| 83 | ma.Type = n |
| 84 | } |
| 85 | |
| 86 | // DupMappedAtt creates a deep copy of ma. |
| 87 | func DupMappedAtt(ma *MappedAttributeExpr) *MappedAttributeExpr { |
no test coverage detected