How do I apply the Law of Demeter to this?
-
11-11-2019 - |
سؤال
I have an admittedly ugly query to do, to find a particular role related to the current role. This line produces the correct result:
@person_event_role.event_role.event.event_roles.
joins(:mission_role).where(:mission_roles => {:title => 'Boss'}).
first.person_event_roles.first.person
(You can infer the associations from the plurality of those calls)
The only way to get this information requires a ton of knowledge of the structure of the database, but to remove the coupling... It would require filling in a bunch of helper functions in each step of that chain to give back the needed info...
لا يوجد حل صحيح
لا تنتمي إلى StackOverflow