Support conditions in link statements

This commit is contained in:
Konstantin Munteanu
2018-09-01 13:30:51 +02:00
parent 05e5ba6939
commit 0d3999c36d
6 changed files with 59 additions and 3 deletions

View File

@@ -238,6 +238,15 @@ link :other, 'https://example.com/resource'
link(:posts) { link_author_posts_url(object) }
```
Just like attributes, links also support conditions in options
```ruby
link(:secret, if: :internal?) { object.secret_link }
def internal?
instance_options[:context] == :internal
end
```
#### #object
The object being serialized.