ruby-grape / ruby-grape/grape-entity
Custom Entity options support
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 729
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
It would be great to be able to provide custom options for entity exposure like:
expose :name, custom: { key: 'value' }
Not only option named custom but any other name as well. It might be helpful sometimes
Now such custom options not allowed ant an exception is throwing:
/gems/grape-entity-1.0.0/lib/grape_entity/entity.rb:624:in `block in valid_options': :custom is not a valid option. (ArgumentError):
raise ArgumentError, "#{key.inspect} is not a valid option." unless OPTIONS.include?(key)
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 in lib/grape_entity/entity.rb at valid_options, around line 624, and review how expose options are validated. Reproduce the shown :custom ArgumentError, then determine how arbitrary named options should be accepted for entity exposure; done means the example and other option names no longer raise that validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100