This is a proof-of-concept for relationships without using an ORM in ColdFusion (specifically, ColdBox — you can replace "wirebox" with your favorite DI framework).
The API I'm trying to get is borrowed from Laravel. We are not using an ORM, though, and have traditionally handled the requests using a {Object}Service -> {Object}DAO -> {Object} pattern. This is my attempt to create the nice relationship syntax found in Laravel for our non-ORM stack.
Things I want to keep:
- the great syntax:
user.roles() - the fact that the related objects are not created unless called
- not having to call a different method or pass a different parameter to the service to compose the relationships
- (though, if you have a strong opinion about that, I'm interested in at least hearing why)
I'd love comments on this. I'm trying to learn the best way to accomplish this given our stack.
Thanks!
More learning — it seems like implicit accessor calls to
get{PropertyName}do not pass throughonMissingMethodwhile explicit calls do.