我在哪里可以找到关于“之前”方法的文档

时间:2023-02-11 15:04:47

I saw this question (Executing code for every method call in a Ruby module) and was interested to see what kinds of other things are built into Ruby.

我看到了这个问题(为Ruby模块中的每个方法调用执行代码),并且有兴趣看看Ruby中内置了哪些其他内容。

Some simple searches didn't bring up anything beyond * questions, so I'm wondering where this information can be found.

一些简单的搜索没有提出堆栈溢出问题之外的任何内容,所以我想知道在哪里可以找到这些信息。

2 个解决方案

#1


1  

The before method from you linked question is not built into Ruby. Instead, it is a custom built "extension" (in fact, an ordinary module, depending on the actual implementation) that gets included and manipulates some methods, typically be defining a new one with the same name as the old one which does something and then calls the old one.

来自你链接问题的before方法没有构建到Ruby中。相反,它是一个自定义构建的“扩展”(事实上,一个普通的模块,取决于实际的实现),它被包含并操纵一些方法,通常是定义一个与旧的相同名称的新扩展名。然后拨打旧的。

While this kind of meta-programming is rather easy with ruby, the specific functionality is not a actually Ruby feature. Instead, it is a partial implementation of Aspect Oriented Programming that is possible due to Ruby's meta-programming capabilities.

虽然这种元编程对于ruby来说相当容易,但具体的功能并不是实际的Ruby功能。相反,由于Ruby的元编程功能,它是面向方面编程的部分实现。

#2


0  

The before method in the question you linked to is not part of Ruby. It is a user-defined method.

你链接的问题中的before方法不是Ruby的一部分。它是用户定义的方法。

#1


1  

The before method from you linked question is not built into Ruby. Instead, it is a custom built "extension" (in fact, an ordinary module, depending on the actual implementation) that gets included and manipulates some methods, typically be defining a new one with the same name as the old one which does something and then calls the old one.

来自你链接问题的before方法没有构建到Ruby中。相反,它是一个自定义构建的“扩展”(事实上,一个普通的模块,取决于实际的实现),它被包含并操纵一些方法,通常是定义一个与旧的相同名称的新扩展名。然后拨打旧的。

While this kind of meta-programming is rather easy with ruby, the specific functionality is not a actually Ruby feature. Instead, it is a partial implementation of Aspect Oriented Programming that is possible due to Ruby's meta-programming capabilities.

虽然这种元编程对于ruby来说相当容易,但具体的功能并不是实际的Ruby功能。相反,由于Ruby的元编程功能,它是面向方面编程的部分实现。

#2


0  

The before method in the question you linked to is not part of Ruby. It is a user-defined method.

你链接的问题中的before方法不是Ruby的一部分。它是用户定义的方法。