tchandy/octopus — pull request #283 by djudd (2014-10-09 21:26:56+00:00)
Title: Allow use of Octopus with models with custom connection

Only for whitelisted shards, optionally specified by setting a class
attribute via 'allow_shard' on a model which also calls
octopus_establish_connection.

So you can say:

```
class CustomConnectedModel
octopus_establish_connection(...)
allow_shard :my_shard
end
```

And then:

```
CustomConnectedModel.first # uses custom connection
CustomConnectedModel.using(:my_shard).first # uses my_shard
CustomConnectedModel.using(:another_shard) # still uses custom connection
```

The use case is a model I have that lives in a separate database,
which I do not normally want to have to think about when using it,
but I would like to be able to call "using(:separate_db_replica)"
with an Octopus-managed shard to access a replica for the model
to distribute read load.

Whitelisting shards explicitly helps prevent errors due to accidental attempts
to use shards which do not include the model's table when using `includes`
or in other ActiveRecord association scenarios.