grape-entity icon indicating copy to clipboard operation
grape-entity copied to clipboard

Responds to the object itself

Open yuuu opened this issue 6 years ago • 1 comments

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?

yuuu avatar Jun 12 '18 08:06 yuuu

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

al avatar Aug 10 '18 11:08 al