Hi,
Quick software design question that I’m trying to get some clarity on.
Question
I’d like to show Article/OrderArticle with some adapted fields for display purposes. Would a proxy object, assigned in the controller, be a sensible approach? To work on price/kg instead of the full unit e.g. a box of “10kg”. This would adapt unit, unit_quantity, quantity, tolerance, result and price.
Background
I’d like to work with two kinds of units in foodsoft, supplier and foodcoop (for unit_subdivide - #209, foodcoop-adam#101).
Supplier units are shown when working with the supplier (fax, receive), foodcoop units are shown when members interact with the system (ordering, show articles_by/groups, …).
My idea is to have the controller generate a proxy object when foodcoops units are shown.
Perhaps Draper with different decorators for the same object would be a somewhat clean approach. Not sure if Draper is meant for having different decorators for the same object.
I’ve got a working hack that multiplies/divides in the view directly, but that’s not really maintainable.
If you have any thoughts on this, welcome!
Best,
- Willem