README.md in restpack_serializer-0.2.8 vs README.md in restpack_serializer-0.2.9

- old
+ new

@@ -29,14 +29,10 @@ ```ruby class AlbumSerializer include RestPack::Serializer attributes :id, :title, :year, :artist_id, :href - - def href - "/albums/#{id}.json" - end end ``` `AlbumSerializer.as_json(album)` produces: @@ -50,11 +46,11 @@ } ``` ## Exposing an API -The `AlbumSerializer` provides `page` and `resource` method which provide paged collection and singular resource GET endpoints. +The `AlbumSerializer` provides `page` and `resource` methods which provide paged collection and singular resource GET endpoints. ```ruby class AlbumsController < ApplicationController def index render json: AlbumSerializer.page(params) @@ -69,11 +65,11 @@ These endpoint will live at URLs such as `/albums.json` and `/albums/142857.json`: * http://restpack-serializer-sample.herokuapp.com/albums.json * http://restpack-serializer-sample.herokuapp.com/albums/4.json -Both `page` and `resource` methods can have an optional scope allowing us to enforce arbitrary constraints: +Both `page` and `resource` methods take an optional scope argument allowing us to enforce arbitrary constraints: ```ruby AlbumSerializer.page(params, Albums.where("year < 1950")) ``` @@ -100,11 +96,11 @@ "album": "1" } }, { "id": "5", - "title": "Treedfingers", + "title": "Treefingers", "href": "/songs/5.json", "links": { "artist": "1", "album": "1" } @@ -125,11 +121,13 @@ "page_size": 3, "count": 42, "includes": [], "page_count": 14, "previous_page": 1, - "next_page": 3 + "next_page": 3, + "previous_href": "/api/v1/songs.json?page_size=3", + "next_href": "/api/v1/songs.json?page=3&page_size=3" } }, "links": { "songs.artist": { "href": "/artists/{songs.artist}.json", @@ -154,15 +152,12 @@ ```ruby class AlbumSerializer include RestPack::Serializer attributes :id, :title, :year, :artist_id, :href + can_include :songs, :artists - - def href - "/albums/#{id}.json" - end 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: @@ -224,10 +219,12 @@ "includes": [ "artists" ], "page_count": 1, "previous_page": null, - "next_page": null + "next_page": null, + "previous_href": null, + "next_href": null } }, "links": { "albums.songs": { "href": "/songs.json?album_id={albums.id}",