engine: traits: Make encoded fields public

The fields that we might want to store with encoding/gob or any other
encoding package, need to be public. We currently don't use any of these
at the moment, but we might in the future.
This commit is contained in:
James Shubin
2019-03-06 10:06:01 -05:00
parent efef260764
commit 8da0da02d9
7 changed files with 94 additions and 26 deletions

View File

@@ -25,7 +25,9 @@ import (
// to support meta parameters. It should be used as a starting point to avoid
// re-implementing the straightforward meta methods.
type Meta struct {
meta *engine.MetaParams
// Xmeta is the stored meta. It should be called `meta` but it must be
// public so that the `encoding/gob` package can encode it properly.
Xmeta *engine.MetaParams
// Bug5819 works around issue https://github.com/golang/go/issues/5819
Bug5819 interface{} // XXX: workaround
@@ -33,14 +35,14 @@ type Meta struct {
// MetaParams lets you get or set meta params for this trait.
func (obj *Meta) MetaParams() *engine.MetaParams {
if obj.meta == nil { // set the defaults if previously empty
obj.meta = engine.DefaultMetaParams.Copy()
if obj.Xmeta == nil { // set the defaults if previously empty
obj.Xmeta = engine.DefaultMetaParams.Copy()
}
return obj.meta
return obj.Xmeta
}
// SetMetaParams lets you set all of the meta params for the resource in a
// single call.
func (obj *Meta) SetMetaParams(meta *engine.MetaParams) {
obj.meta = meta
obj.Xmeta = meta
}