README.md in jsonapi-serializers-0.3.1 vs README.md in jsonapi-serializers-0.4.0
- old
+ new
@@ -12,10 +12,11 @@
* [Usage](#usage)
* [Define a serializer](#define-a-serializer)
* [Serialize an object](#serialize-an-object)
* [Serialize a collection](#serialize-a-collection)
* [Null handling](#null-handling)
+ * [Multiple attributes](#multiple-attributes)
* [Custom attributes](#custom-attributes)
* [More customizations](#more-customizations)
* [Base URL](#base-url)
* [Root metadata](#root-metadata)
* [Relationships](#relationships)
@@ -147,10 +148,17 @@
}
```
Note that the JSON:API spec distinguishes in how null/empty is handled for single objects vs. collections, so you must always provide `is_collection: true` when serializing multiple objects. If you attempt to serialize multiple objects without this flag (or a single object with it on) a `JSONAPI::Serializer::AmbiguousCollectionError` will be raised.
+### Multiple attributes
+You could declare multiple attributes at once:
+
+```ruby
+ attributes :title, :body, :contents
+```
+
### Custom attributes
By default the serializer looks for the same name of the attribute on the object it is given. You can customize this behavior by providing a block to `attribute`, `has_one`, or `has_many`:
```ruby
@@ -517,9 +525,10 @@
* Support for the `fields` spec is planned, would love a PR contribution for this.
* Support for pagination/sorting is unlikely to be supported because it would likely involve coupling to ActiveRecord, but please open an issue if you have ideas of how to support this generically.
## Release notes
+* v0.4.0: Support for declaring multiple `attributes`.
* v0.3.1: Improve performance of loading included relationships.
* v0.3.0: Add top-level `meta` support.
* v0.2.6: Add `base_url` support.
* v0.2.5: Allow disabling ambiguous collection checks for Sequel support.
* v0.2.4: Improve handling for nil relationship links.