dblock/mongoid-cached-json — pull request #2 by dblock (2012-02-21 13:36:25+00:00)
Title: Added support for versionned JSON

Mongoid::CachedJson now supports JSON versionning with json_fields_for. The obvious use-case is to return different JSON versions from API v1 and API v2. For example, version 2 of Widget splits name into first and last.

```
class Widget
include Mongoid::CachedJson

field :first
field :last

json_fields_for :v1 \
:name => { :definition => lambda { |instance| "#{instance.first} #{instance.last}" } }

json_fields_for :v2 \
:first => { },
:last => { }

end
```

JSON fields declared with json_fields instead of json_fields_for are used for all versions.