From 41c1e0a106d97de9f48fb6ce427b921c4a8a5d9d Mon Sep 17 00:00:00 2001 From: Erol Date: Mon, 16 Jul 2018 06:19:54 +0800 Subject: [PATCH] Add proc shortcut use case to README --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index f4333d1..c812eac 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,18 @@ class MovieSerializer end ``` +Attributes can also use a different name by passing the original method or accessor with a proc shortcut: + +```ruby +class MovieSerializer + include FastJsonapi::ObjectSerializer + + attributes :name + + attribute :released_in_year, &:year +end +``` + ### Links Per Object Links are defined in FastJsonapi using the `link` method. By default, link are read directly from the model property of the same name.In this example, `public_url` is expected to be a property of the object being serialized.