The hook of Kernel.eval does not happen in the right module/class context. Therefore if you try and eval a string like this:
module MyModule
eval "class Foo; end"
end
The constant Foo is defined on AppMap::Hook::Method rather than on MyModule. We would like to hook eval so that any new constants are defined on the right module.
This could also be the root cause of the note that I left in ruby.yml:
# These methods cannot be hooked as far as I can tell.
# Why? When calling one of these functions, the context at the point of
# definition is used. It's not possible to bind class_eval to a new context.
# - Module#class_eval
# - Module#module_eval
The hook of
Kernel.eval
does not happen in the right module/class context. Therefore if you try and eval a string like this:The constant
Foo
is defined onAppMap::Hook::Method
rather than onMyModule
. We would like to hookeval
so that any new constants are defined on the right module.PS Is there any other way to dynamically evaluate a language string in Ruby? If so, we would need to fix this there as well. I think so :
class_eval
andclass_exec
- https://ruby-doc.org/core-2.6/Module.html#method-i-class_evalThis could also be the root cause of the note that I left in
ruby.yml
: