RE: [coldbox:15743] Re: Wirebox initWith() - pass object by map reference

I don’t think it would end up much cleaner. For initWith to support all the functionality of initArg would require each argument to be a struct containing corresponding keys for ref, dsl, value, and javaCast. So your example would look more like:

argStruct = {
coldbox = {
value = getColdBox()
},
gateway = {
name = “UserGateWay”
},
objectType = {
value = “User”
}
};

mapPath(“model.user.UserService”).asSingleton().initWith(argumentCollection = argStruct);

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Yeap that’s yeuk :slight_smile:

Why does initWith() have to support everything initArg() does though? It doesn’t seem to have the same behaviour unless there is something buried in WB that requires it to be like that.

Could you not just pass through an argument struct in the same way you would normally call a method and let it handle the correct type?

A couple of examples I’ve setup just now in my configuration:-

argStruct = {

Coldbox = getColdBox(),

objectType = “User”

};

mapPath(“model.user.UserService”).asSingleton().initWith(argumentCollection=argStruct);