maccman/spine — pull request #312 by stephenvisser (2012-05-26 05:57:32+00:00)
Title: Routes in Controllers should not affect global behaviour

This has been mentioned several times (#159, #140) but to my knowledge has not been addressed.

It is even noted in the [Spine documentation](http://spinejs.com/docs/events) in reference to the pitfalls of using global events:

However, keep in mind that is often not such a great idea, as it introduces a degree of coupling into your code. Always ask yourself if you can use routes instead, or perhaps local controller events.

Currently, when a user adds routes in controller context, changes are implicitly made globally. This is dangerous, anti-intuitive, and breaks encapsulation. My changes support adding routes as per normal at the global level, but when using them in controllers, uses the `addMap` function. This function adds routes in contextual chunks so that routes matched by one controller won't affect the results in a different controller.

There is one glaring exception to this rule that exists for reasons of backwards-compatability. When __ANY__ matching routes were declared in the global Route object using the regular old `add` function, __NO__ routes at the controller level will be notified.