ruby-grape / grape-entity

An API focused facade that sits on top of an object model.
MIT License
715 stars 153 forks source link

Add default value option #352

Closed ahmednaguib closed 3 years ago

ahmednaguib commented 3 years ago

Description

I noticed there is no direct way of defining default value for expose when a field is returning nil. Of course there is a way to do it via a block but would be a nice option to have it like this: expose :x, default: 0

I also saw there is an issue opened https://github.com/ruby-grape/grape-entity/issues/327 asking for the feature so I made the pr maybe it will be useful for other folks.

LeFnord commented 3 years ago

sorry @ahmednaguib for the late reply