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

Function wrapProjected

codegen/service/service_data.go:2096–2117  ·  view source on GitHub ↗

wrapProjected builds a viewed result type by wrapping the given projected in a result type with "projected" and "view" attributes.

(projected expr.UserType)

Source from the content-addressed store, hash-verified

2094// wrapProjected builds a viewed result type by wrapping the given projected
2095// in a result type with "projected" and "view" attributes.
2096func wrapProjected(projected expr.UserType) expr.UserType {
2097 rt := projected.(*expr.ResultTypeExpr)
2098 pratt := &expr.NamedAttributeExpr{
2099 Name: "projected",
2100 Attribute: &expr.AttributeExpr{Type: rt, Description: "Type to project"},
2101 }
2102 prview := &expr.NamedAttributeExpr{
2103 Name: "view",
2104 Attribute: &expr.AttributeExpr{Type: expr.String, Description: "View to render"},
2105 }
2106 return &expr.ResultTypeExpr{
2107 UserTypeExpr: &expr.UserTypeExpr{
2108 AttributeExpr: &expr.AttributeExpr{
2109 Type: &expr.Object{pratt, prview},
2110 Validation: &expr.ValidationExpr{Required: []string{"projected", "view"}},
2111 },
2112 TypeName: rt.TypeName,
2113 },
2114 Identifier: rt.Identifier,
2115 Views: rt.Views,
2116 }
2117}
2118
2119// buildTypeInits builds the data to generate the constructor code to
2120// initialize a result type from a projected type.

Callers 1

buildViewedResultTypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected