refinery/refinerycms — pull request #2637 by ghoppe (2014-07-24 20:34:02+00:00)
Title: Refactor PageFinder

A (relatively) brief explanation of why I did this:

I was using the new master branch, including the new refactoring done with PageFinder by @awagener and I ran into a bit of an annoying issue. After I would make changes to a custom extension model, then reload the page in development, Refinery would return with an error `uninitialized constant PageFinder`. If I restarted the development server the error would go away.

Now I don't know enough about Rails internals to know why the PageFinder would be "forgotten" by the Page model just because a seemingly unrelated model changed, but I took a closer look at the code. The first thing I wondered was why page_finder.rb was in app/models and not lib/refinery/pages like what seemed to me similar url methods. Shouldn't things in pages/app/models/refinery belong to Refinery::Core::BaseModel?

So I decided to try moving page_finder.rb to lib/refinery/pages and namespace it there. Then, seemingly like magic, now that it's namespaced under `Pages` more semantically elegant method names presented themselves. Then I realized, hey `Find` would look better than `Finder`!

Anyway, the important thing to me is that after this refactoring the error went away! I could make changes and check them without needing to restart the server. If this refactoring is out to lunch and offensive to anyone let me know of a better way to get over that error. :)

Cheers,
Glenn