ruby-grape / ruby-grape/grape-entity
Adding default value to expose
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 729
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
Is there a way to add a default value to expose in case of the value is not present?
For example
expose :tags do |filter|
filter[:tags].present? ? filter[:tags] : "all"
end
could be replaced by
expose :tags, default: "all"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the expose entry point and the tests covering exposed values. Check how missing values are currently handled and whether option arguments are already supported. Done means expose :tags, default: "all" supplies the default when the value is absent, while existing block-based behavior remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100