SwiftSuspenders
SwiftSuspenders copied to clipboard
Feature Request -- "Mapping"-specific injections
After using this framework extensively, one thing I found myself repeatedly wanting was a way for it to help me cleanly separate configuration from behavior.
Currently, to satisfy this need, I rely on name-qualified injection points which unfortunately are highly coupled with the class instead of the mapped object's key.
class Poo{
[Inject(name="poo.stink")]
public var stink:Stink;
}
What I would like to see is something like the following:
injector.map('application.somepoint')
.toType(flash.geom.Point)
.withArgument(50)
.withProperty('y',100);
const point:Point = injector.getInstance('application.somepoint') as Point;
assertEquals(50, point.x); // true
assertEquals(100, point.y); // true
Much like an object mocking framework, this feature would greatly increase the re-usability of classes -- eliminating the need to rely on inheritance models resulting in class explosion.
Thoughts?