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

Function TaggedAttribute

expr/attribute.go:168–188  ·  view source on GitHub ↗

TaggedAttribute returns the name of the child attribute of a with the given tag if a is an object.

(a *AttributeExpr, tag string)

Source from the content-addressed store, hash-verified

166// TaggedAttribute returns the name of the child attribute of a with the given
167// tag if a is an object.
168func TaggedAttribute(a *AttributeExpr, tag string) string {
169 obj := AsObject(a.Type)
170 if obj == nil {
171 return ""
172 }
173 for _, at := range *obj {
174 if _, ok := at.Attribute.Meta[tag]; ok {
175 return at.Name
176 }
177 }
178 for _, b := range a.Bases {
179 at := &AttributeExpr{Type: b}
180 if ut, ok := b.(UserType); ok {
181 at = ut.Attribute()
182 }
183 if n := TaggedAttribute(at, tag); n != "" {
184 return n
185 }
186 }
187 return ""
188}
189
190// walkAttribute iterates over the given attribute, its bases and references
191// (if any). It calls the given function giving each attribute as it iterates.

Callers 7

BuildSchemeDataFunction · 0.92
FinalizeMethod · 0.85
getSecurityAttributesFunction · 0.85
FinalizeMethod · 0.85
TestTaggedAttributeFunction · 0.85

Calls 2

AsObjectFunction · 0.85
AttributeMethod · 0.65

Tested by 1

TestTaggedAttributeFunction · 0.68