[英]How to search defined constants in ruby
How can I show all defined constants with the word "AjaxDatatablesRails"
in it? 如何显示所有带有
"AjaxDatatablesRails"
字样的已定义常量?
I tried this: 我尝试了这个:
::AjaxDatatablesRails::Extensions
# >> NameError: uninitialized constant AjaxDatatablesRails::Extensions
Module.constants.grep /AjaxDatatablesRails/
Module.constants
returns an array of the names of all constants accessible from the point of call. Module.constants
返回从调用点可以访问的所有常量的名称的数组。
Enumerable#grep
then loops through this array, and filters out the names matching the given pattern. 然后,
Enumerable#grep
遍历此数组,并过滤出与给定模式匹配的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.