Closed ahmednaguib closed 3 years ago
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
expose
nil
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.
sorry @ahmednaguib for the late reply
Description
I noticed there is no direct way of defining default value for
expose
when a field is returningnil
. 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.