Add proc shortcut use case to README
This commit is contained in:
parent
5c8e9358f2
commit
abc830b41e
12
README.md
12
README.md
@ -207,6 +207,18 @@ class MovieSerializer
|
|||||||
end
|
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 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.
|
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.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user