Skip to content

Commit

Permalink
feature: Added a new ValueSource ValueGenerator.
Browse files Browse the repository at this point in the history
Signed-off-by: zhouchenh <[email protected]>
  • Loading branch information
zhouchenh committed Jun 22, 2021
1 parent 4944f5c commit 98eceb9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type (
DefaultValue struct {
Value interface{}
}

ValueGenerator func(i interface{}) (object interface{}, ok bool)
)

var Root = RootAsPath{}
Expand Down Expand Up @@ -265,6 +267,11 @@ func (dv DefaultValue) ExtractObject(interface{}) (object interface{}, ok bool)
return dv.Value, true
}

func (vg ValueGenerator) ExtractObject(data interface{}) (object interface{}, ok bool) {
object, ok = vg(data)
return
}

func (vs ValueSources) ExtractObject(data interface{}) (object interface{}, ok bool) {
for _, valueSource := range vs {
if valueSource == nil {
Expand Down

0 comments on commit 98eceb9

Please sign in to comment.