Open tslocke opened 8 years ago
If the maintainers think this would make a good enhancement to Draper I would be happy to submit a PR.
I do think so. If we already have context
there, this add-on is going to add no more complexity, I guess, nor should it interfere with anything 🤔
We should still respect context[:owner]
if one has been passed explicitly.
I'm sorry for the answer taking so long. I'm quite new here, trying to dig through all the issues.
Imagine a stock portfolio app where a user has_many companies. Say I want to list the value of a user's portfolio broken down by company.
I could add a method
portfolio_value(user)
to the company decorator, and doBut given I accessed the company via
user.companies
, the user could already be available in the context of the company decorator, and I could do simply:In my experience this is a common pattern in many apps.
A simple monkey patch to achieve this is:
I've been using this patch and found it very useful. If the maintainers think this would make a good enhancement to Draper I would be happy to submit a PR.