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

Method Inherit

expr/attribute.go:419–429  ·  view source on GitHub ↗

Inherit merges the properties of existing target type attributes with the argument's. The algorithm is recursive so that child attributes are also merged.

(parent *AttributeExpr)

Source from the content-addressed store, hash-verified

417// argument's. The algorithm is recursive so that child attributes are also
418// merged.
419func (a *AttributeExpr) Inherit(parent *AttributeExpr) {
420 if !a.shouldInherit(parent) {
421 return
422 }
423 pobj := AsObject(parent.Type)
424 if a.Type == Empty && len(*pobj) > 0 {
425 a.Type = &Object{}
426 }
427 a.inheritValidations(parent)
428 a.inheritRecursive(parent, make(map[*AttributeExpr]struct{}))
429}
430
431// AllRequired returns the list of all required fields from the underlying
432// object. This method recurses if the type is itself an attribute (i.e. a

Callers 2

FinalizeMethod · 0.95
extendBodyAttributeFunction · 0.80

Calls 4

shouldInheritMethod · 0.95
inheritValidationsMethod · 0.95
inheritRecursiveMethod · 0.95
AsObjectFunction · 0.85

Tested by

no test coverage detected