2
0

Add Numeric.Getter

This commit is contained in:
Jack Christensen
2021-09-02 15:55:50 -05:00
parent 1a3e5b0266
commit 55195b3a64
+6
View File
@@ -62,11 +62,13 @@ type Numeric struct {
Valid bool Valid bool
NumericDecoderWrapper func(interface{}) NumericDecoder NumericDecoderWrapper func(interface{}) NumericDecoder
Getter func(Numeric) interface{}
} }
func (n *Numeric) NewTypeValue() Value { func (n *Numeric) NewTypeValue() Value {
return &Numeric{ return &Numeric{
NumericDecoderWrapper: n.NumericDecoderWrapper, NumericDecoderWrapper: n.NumericDecoderWrapper,
Getter: n.Getter,
} }
} }
@@ -258,6 +260,10 @@ func (dst *Numeric) Set(src interface{}) error {
} }
func (dst Numeric) Get() interface{} { func (dst Numeric) Get() interface{} {
if dst.Getter != nil {
return dst.Getter(dst)
}
if !dst.Valid { if !dst.Valid {
return nil return nil
} }