MCPcopy Create free account
hub / github.com/goadesign/goa / Remap

Method Remap

expr/mapped_attribute.go:66–84  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

64// the underlying attribute is modified after the mapped attribute has been
65// initially created.
66func (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.
87func DupMappedAtt(ma *MappedAttributeExpr) *MappedAttributeExpr {

Callers 5

NewMappedAttributeExprFunction · 0.95
MergeMethod · 0.95
HeaderFunction · 0.80
CookieFunction · 0.80
ParamFunction · 0.80

Calls 3

AsObjectFunction · 0.85
SetMethod · 0.80
ExtractUserExamplesMethod · 0.80

Tested by

no test coverage detected