homeserve-alliance/geocoder — pull request #3 by rob-murray (2014-05-30 11:40:28+00:00)
Title: Add lookup fallback

This allows you to configure a 'fallback' lookup service on a specified Error. An example use could be to use a primary API by default but fallback to a secondary service if the primary returns an "over usage" limit so that you always get a response.

### Default behaviour

By default Geocoder will simply use the specified (either configured or default) lookup and the behaviour is as before.

### With a fallback

When a fallback is configured, the Query is performed on the primary service/lookup and if successful then the results are returned, however if this lookup happens to raise the Error that is specified then the same query will be performed on the secondary lookup and results returned from this. If this fails then the behaviour is as before, the error is either raised or ignored.

Configured as follows;

```ruby
# config/initializers/geocoder.rb
Geocoder.configure(

# geocoding service (see below for supported options):
:lookup => :yandex,

# fallback to another provider on specific error
:lookup_fallback => {
:to => :google,
:on => Geocoder::OverQueryLimitError
})
```