fnando/redis-settings — pull request #5 by brickattack (2014-04-09 20:01:21+00:00)
Title: Add preferential_settings, getter/setters, and optional encryption

This adds a class method to all ActiveRecord::Base models that allows you to set "preferential settings".

Backstory:
We find it useful to be able to encrypt settings on our side when necessary. We also use this to set default values for settings after_create. In addition, we give each setting its own getter and setter method right on our model.

For example:

```ruby
# config/initializers/redis_settings.rb
Redis::Settings.configure do |config|
config.encryptor = MyEncryptor.new
end
```

```ruby
# some_model.rb
class SomeModel < ActiveRecord::Base
self.preferential_settings = {
external_api_key: {
encrypted: true
},
report_template: {
default: 'fancy_report'
}
}

after_create :ensure_preferential_settings!
end
```

Now whenever I create a new SomeModel object, I get the following
```ruby
obj = SomeModel.create!
obj.report_template #=> 'fancy_report'

obj.external_api_key = 'super secret' #=> will use MyEncryptor instance methods encrypt! and decrypt! to store and retrieve data from redis, respectively
```