grape-entity
grape-entity copied to clipboard
Responds to the object itself
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?
If I understand you correctly, I think expose :itself, as: :body
would work and is slightly prettier. Does that help?