http://jsonapi.org/format/#document-top-level
fix failing tests
support for top-level links limited to jsonapi adapter
Move docs from README to docs/ dir
move links to json-api adapter & create Links class to hold links data
Changes:
- Introduce Adapter::get for use by Serializer.adapter
- Move Adapter-finding logic from Adapter::adapter_class into Adapter::get
Introduced interfaces:
- non-inherited methods
```ruby
ActiveModel::Serializer::Adapter.adapter_map # a Hash<adapter_name, adapter_class>
ActiveModel::Serializer::Adapter.adapters # an Array<adapter_name>
ActiveModel::Serializer::Adapter.register(name, klass) # adds an adapter to the adapter_map
ActiveModel::Serializer::Adapter.get(name_or_klass) # raises Argument error when adapter not found
```
- Automatically register adapters when subclassing
```ruby
def self.inherited(subclass)
ActiveModel::Serializer::Adapter.register(subclass.to_s.demodulize, subclass)
end
```
- Preserves subclass method `::adapter_class(adapter)`
```ruby
def self.adapter_class(adapter)
ActiveModel::Serializer::Adapter.get(adapter)
end
```
- Serializer.adapter now uses `Adapter.get(config.adapter)` rather than have duplicate logic
It's a new implementation of cache based on ActiveSupport::Cache.
The implementation abstracts the cache in Adapter class on a
private method called cached_object, this method is intended
to be used on Adapters inside serializable_hash method in order
to cache each instance of the object that will be returned by
the serializer.
Some of its features are:
- A different syntax. (no longer need the cache_key method).
- An options argument that have the same arguments of ActiveSupport::Cache::Store, plus a key option that will be the prefix of the object cache on a pattern "#{key}-#{object.id}".
- It cache the objects individually and not the whole Serializer return, re-using it in different requests (as a show and a index method for example.)
The options passed to the render are partitioned into adapter options
and serializer options. 'include' and 'root' are sent to the adapter,
not sure what options would go directly to serializer, but leaving this
in until I understand that better.