Closed
Description
I'm looking to expose using different entities if a user is anonymous or not:
class MediaEntity < Grape::Entity
expose :id
expose :user, using: Entities::UserEntity, if: lambda { |object, options| object.anonymous == false }
expose :user, using: Entities::AnonymousUserEntity, if: lambda { |object, options| object.anonymous == true }
end
present :data, media, with: MediaEntity
This doesn't work as you documented in the caveat section. Is there a good workaround?
Also, do you have a solution in mind for this?