ruby-on-rails - 对象常量的内部结构

标签 ruby-on-rails ruby

阅读 Rails 指南时,我注意到实际的对象常量存储一个表。

First, when the module keyword is processed, the interpreter creates a new entry in the constant table of the class object stored in the Object constant. Said entry associates the name "Colors" to a newly created module object. Furthermore, the interpreter sets the name of the new module object to be the string "Colors"

但是,当我尝试访问对象时,它只是返回

=> Object

有没有办法访问 Ruby 中对象常量的内部结构?或许可以瞥见带有所述 Module-object-to-name 的表格 映射。

最佳答案

Module.constants # ==> All constants 可能对你有帮助。

关于ruby-on-rails - 对象常量的内部结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47043926/

相关文章:

ruby-on-rails - 使用 twitter 设计/omniauth 登录 - 验证失败 : email can't be blank

ruby-on-rails - 关注的多态关联的 Rails 逆向给出 TypeError : can't cast Class

javascript - 如何通过循环动态设置实例变量?

Mysql2::Error: 指定的键太长;对于只有 87 个 db 字段的表,最大 key 长度为 767 字节

ruby-on-rails - 按 updated_at 对 ruby​​ 数组排序

ruby-on-rails - 如何使用 ruby​​ on Rails 在 html 中输出希腊符号

ruby-on-rails - Localhost :3000 claims "gem ' pg'"in not installed, Heroku 应用运行正常

ruby - 检查GitLab API访问: FAILED.代码:404

并行运行时,Ruby 1.9.3 不运行任何单元测试

ruby-on-rails - 为 Rails 配置 nginx.conf 显示文件目录而不是索引