继承无法与葡萄实体及其= 0.5.0合作。

发布于 2025-02-04 20:03:25 字数 795 浏览 2 评论 0原文

module API
  module V1
    module Entities
      class A < Grape::Entity
        expose :k 
        expose :l
        expose :status 

        def status
         'HI'
        end
      end
    end
  end
end

module API
  module V101
    module Entities
      class A < V1::Entities::A
        expose :status

        def status
         'BYE'
        end
      end
    end
  end
end

在这种情况下,使用葡萄的实用性,当我调用v101时,它正在调用status v1的功能,而不是v101。这意味着 - 首先,它执行status v1的功能,然后是v101。此代码完美地与Grape-entity 版本= 0.4.8一起使用,其中仅调用v101的函数。 版本&gt; = 0.5此代码不像以前那样行事。我想念什么吗?谢谢你!

Related Configuration
rails: 5.2
grape: 1.6.2
module API
  module V1
    module Entities
      class A < Grape::Entity
        expose :k 
        expose :l
        expose :status 

        def status
         'HI'
        end
      end
    end
  end
end

module API
  module V101
    module Entities
      class A < V1::Entities::A
        expose :status

        def status
         'BYE'
        end
      end
    end
  end
end

In this case with grape-entity, when I am calling the V101 it is calling the status function of V1 instead of the V101 at first. This means - first it is executing the status function of v1 and then v101. This code perfectly works with the grape-entity version = 0.4.8 where it only calls the function of v101 when I call with v101. After version >= 0.5 this code does not behave as before. Ami I missing something? Thank you!

Related Configuration
rails: 5.2
grape: 1.6.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文