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

Function Extend

dsl/result_type.go:455–468  ·  view source on GitHub ↗

Extend adds the parameter type attributes to the type using Extend. The parameter type must be an object. Extend may be used in Type or ResultType. Extend accepts a single argument: the type or result type containing the attributes to be copied. Example: var CreateBottlePayload = Type("CreateBot

(t expr.DataType)

Source from the content-addressed store, hash-verified

453// Extend(CreateBottlePayload) // Adds attributes "name" and "vintage"
454// })
455func Extend(t expr.DataType) {
456 if !expr.IsObject(t) {
457 eval.ReportError("argument of Extend must be an object, got %s", t.Name())
458 return
459 }
460 switch def := eval.Current().(type) {
461 case *expr.ResultTypeExpr:
462 def.Bases = append(def.Bases, t)
463 case *expr.AttributeExpr:
464 def.Bases = append(def.Bases, t)
465 default:
466 eval.IncompatibleDSL()
467 }
468}
469
470// Attributes implements the result type Attributes DSL. See ResultType.
471func Attributes(fn func()) {

Callers 8

endpoint_dsls.goFile · 0.85
result_dsls.goFile · 0.85
payload_dsls.goFile · 0.85
dsls.goFile · 0.85
types_dsl.goFile · 0.85

Calls 5

IsObjectFunction · 0.92
ReportErrorFunction · 0.92
CurrentFunction · 0.92
IncompatibleDSLFunction · 0.92
NameMethod · 0.65

Tested by

no test coverage detected