ruby-grape / ruby-grape/grape-entity
Responds to the object itself
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 729
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
I want to respond to the specified object itself.
If you program as follows, you will get an error with no body method.
class BodyEntity < Grape::ENtity
expose :body
end
get do
present 'success', with: Entities::BodyEntity
end
As a workaround, we currently program as follows.
class BodyEntity < Grape::ENtity
expose :body do |body|
body
end
end
get do
present 'success', with: Entities::BodyEntity
end
Is not there a better way?
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 reproducing the shown Grape::Entity class with expose :body and the present call, then compare it with the workaround that returns body explicitly. The work is done when the specified object itself can be presented without requiring that workaround; the issue does not name a file or test to update.
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