Skip to content

Commit 41c1e0a

Browse files
Erolshishirmk
authored andcommitted
Add proc shortcut use case to README
1 parent e05193f commit 41c1e0a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ class MovieSerializer
207207
end
208208
```
209209

210+
Attributes can also use a different name by passing the original method or accessor with a proc shortcut:
211+
212+
```ruby
213+
class MovieSerializer
214+
include FastJsonapi::ObjectSerializer
215+
216+
attributes :name
217+
218+
attribute :released_in_year, &:year
219+
end
220+
```
221+
210222
### Links Per Object
211223
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.
212224

0 commit comments

Comments
 (0)