github.com/MontFerret/ferret@v0.18.0/pkg/runtime/expressions/param.go (about) 1 package expressions 2 3 import ( 4 "context" 5 6 "github.com/MontFerret/ferret/pkg/runtime/core" 7 "github.com/MontFerret/ferret/pkg/runtime/values" 8 ) 9 10 type ParameterExpression struct { 11 src core.SourceMap 12 name string 13 } 14 15 func NewParameterExpression(src core.SourceMap, name string) (*ParameterExpression, error) { 16 if name == "" { 17 return nil, core.Error(core.ErrMissedArgument, "name") 18 } 19 20 return &ParameterExpression{src, name}, nil 21 } 22 23 func (e *ParameterExpression) Exec(ctx context.Context, _ *core.Scope) (core.Value, error) { 24 param, err := core.ParamFrom(ctx, e.name) 25 26 if err != nil { 27 return values.None, core.SourceError(e.src, err) 28 } 29 30 return param, nil 31 }