Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responds to the object itself #302

Open
yuuu opened this issue Jun 12, 2018 · 1 comment
Open

Responds to the object itself #302

yuuu opened this issue Jun 12, 2018 · 1 comment

Comments

@yuuu
Copy link

yuuu commented Jun 12, 2018

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?

@al
Copy link

al commented Aug 10, 2018

If I understand you correctly, I think expose :itself, as: :body would work and is slightly prettier. Does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants