objects-on-rails/display-case — pull request #35 by NateBarnes (2013-03-06 05:21:45+00:00)
Title: Smarter exhibit chain

I ran into a business case recently where we had an Article model that was being exhibited with an ArticleExhibit through the Article Controller. All was well until we introduced a GuideController (which was a slightly different way of decorating Articles). So now we have a GuideExhibit and a GuideController.

This was when I noticed that no matter how I sliced it, the ArticleExhibit always took precedence, thus whenever I had two methods of the same names on the exhibits, even though I was in the context of the GuideController, I got the ArticleExhibit version.

So I wrote a quick patch. Basically when it applies the exhibits, it does some quick string matching and if it finds the exhibit name within the name of the context class it gives it (and any others that match), precedence.

Thanks!