wingedmonkey/wingedmonkey — pull request #47 by blomquisg (2012-12-03 18:22:01+00:00)
Title: Add current_provider to model layer

This pull request adds the concept of the "current_provider" to the model object layer by storing the current provider in thread-local storage. The thread-local storage is accessed via a class method on Provider. This way, any object model method that needs to get access to the current provider information can easily grab it.

Additionally, the current credentials supplied by the user are stored in the same thread-local storage by adding a ```credentials``` instance var to the provider base class. When the ```before_filter :require_provider_authentication``` is executed, it updates the thread-local storage with the current_provider and current credentials from the HTTP session.

Model object methods can now call ```Provider.current_provider``` to get the current provider. Also, the ```Provider#connect!``` method was updated so it no longer takes in any arguments. Instead, it reads the credentials from the ```credentials``` instance var.

To get a provider connection, model object methods can call: ```Provider.current_provider.connect!```.

It's possible we may want to add some sugar by adding a ```connect!``` class method directly to ```Provider``` so that the ```current_provider``` piece is implicit. If this pull request is accepted, we can come back to that topic.