From 6af7284d08d58de98e73bf65e12c60ad86626add Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 25 Sep 2019 11:24:19 -0700 Subject: [PATCH] Make CreateModule return the newly created module Allow mutators to modify properties of the newly created module by returning it. Change-Id: Ia1acc70b6196195d1bad58c88ab3def70b99e42c --- module_ctx.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module_ctx.go b/module_ctx.go index bc05787..be5d974 100644 --- a/module_ctx.go +++ b/module_ctx.go @@ -712,7 +712,7 @@ type TopDownMutatorContext interface { // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies // the specified property structs to it as if the properties were set in a blueprint file. - CreateModule(ModuleFactory, ...interface{}) + CreateModule(ModuleFactory, ...interface{}) Module } type BottomUpMutatorContext interface { @@ -934,7 +934,7 @@ func (mctx *mutatorContext) Rename(name string) { mctx.rename = append(mctx.rename, rename{mctx.module.group, name}) } -func (mctx *mutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) { +func (mctx *mutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module { module := mctx.context.newModule(factory) module.relBlueprintsFile = mctx.module.relBlueprintsFile @@ -950,6 +950,8 @@ func (mctx *mutatorContext) CreateModule(factory ModuleFactory, props ...interfa } mctx.newModules = append(mctx.newModules, module) + + return module.logicModule } // SimpleName is an embeddable object to implement the ModuleContext.Name method using a property