gpt4 book ai didi

ruby - 真正的轮胎方法的代理?

转载 作者:行者123 更新时间:2023-12-03 02:09:55 25 4
gpt4 key购买 nike

我正在阅读 Tire gem 的文档我对以下段落的含义感到困惑。有人可以解释一下吗?

In fact, all this time you've been using only proxies to the real Tire methods, which live in the tire class and instance methods of your model. Only when not trampling on someone's foot — which is the majority of cases — will Tire bring its methods to the namespace of your class.

So, instead of writing Article.search, you could write Article.tire.search, and instead of @article.update_index you could write @article.tire.update_index, to be on the safe side. Let's have a look on an example with the mapping method:

最佳答案

它的意思就是它所说的:Tire 尽量不将方法拖到您的模型/命名空间中,并且仅在它们不存在时才定义其方法。

作为普通用户,您不必太在意它。无论何时调用 MyModel.searchMyModel.mapping您也可以调用MyModel.tire.searchMyModel.tire.mapping .

关于ruby - 真正的轮胎方法的代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15041912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com