README.md in restpack_serializer-0.4.6 vs README.md in restpack_serializer-0.4.7
- old
+ new
@@ -118,11 +118,11 @@
"meta": {
"songs": {
"page": 2,
"page_size": 3,
"count": 42,
- "includes": [],
+ "include": [],
"page_count": 14,
"previous_page": 1,
"next_page": 3,
"previous_href": "/api/v1/songs.json?page_size=3",
"next_href": "/api/v1/songs.json?page=3&page_size=3"
@@ -157,19 +157,19 @@
can_include :songs, :artists
end
```
-In this example, we are allowing related `songs` and `artists` to be included in API responses. Side-loads can be specifed by using the `includes` parameter:
+In this example, we are allowing related `songs` and `artists` to be included in API responses. Side-loads can be specifed by using the `include` parameter:
#### No side-loads
* http://restpack-serializer-sample.herokuapp.com/albums.json
#### Side-load related Artists
-* http://restpack-serializer-sample.herokuapp.com/albums.json?includes=artists
+* http://restpack-serializer-sample.herokuapp.com/albums.json?include=artists
which yields:
```javascript
{
@@ -214,11 +214,11 @@
"meta": {
"albums": {
"page": 1,
"page_size": 10,
"count": 4,
- "includes": [
+ "include": [
"artists"
],
"page_count": 1,
"previous_page": null,
"next_page": null,
@@ -267,23 +267,23 @@
}
```
#### Side-load related Songs
-* http://restpack-serializer-sample.herokuapp.com/albums.json?includes=songs
+* http://restpack-serializer-sample.herokuapp.com/albums.json?include=songs
An album `:has_many` songs, so the side-loaded songs are paged. The `meta.songs` includes `previous_href` and `next_href` which point to the previous and next page of this side-loaded data. These URLs take the form:
* http://restpack-serializer-sample.herokuapp.com/songs.json?album_ids=1,2,3,4&page=2
#### Side-load related Artists and Songs
-* http://restpack-serializer-sample.herokuapp.com/albums.json?includes=artists,songs
+* http://restpack-serializer-sample.herokuapp.com/albums.json?include=artists,songs
## Filtering
-Simple filtering based on primary and foreign keys is possible:
+Simple filtering based on primary and foreign keys is supported by default:
#### By primary key:
* http://restpack-serializer-sample.herokuapp.com/albums.json?id=1
* http://restpack-serializer-sample.herokuapp.com/albums.json?ids=1,2,4
@@ -291,8 +291,21 @@
#### By foreign key:
* http://restpack-serializer-sample.herokuapp.com/albums.json?artist_id=1
* http://restpack-serializer-sample.herokuapp.com/albums.json?artist_ids=2,3
+#### Custom filters:
+
+Custom filters can be defined with the `can_filter_by` option:
+
+ ```ruby
+class Account
+ include RestPack::Serializer
+ attributes :id, :application_id, :created_by, :name, :href
+
+ can_filter_by :application_id
+end
+```
+
Side-loading is available when filtering:
- * http://restpack-serializer-sample.herokuapp.com/albums.json?artist_ids=2,3&includes=artists,songs
+ * http://restpack-serializer-sample.herokuapp.com/albums.json?artist_ids=2,3&include=artists,songs