I know that I can create a binding from hashing using ostruct, for example:
require 'ostruct'
not_in_locals = "we don't want this"
locals = {a: 1, b: 2}
my_binding = OpenStruct.new(locals).instance_eval { binding }
p my_binding
p eval("a", my_binding)
p eval("b", my_binding)
p eval("not_in_locals", my_binding)
Here you can see the output that confirms the comments in the code: https://eval.in/132925
As you can see, the problem is that Binding also binds variables in the local context that are not in the Hash. I need a method to create anchor objects from Hash that are not related to anything other than the keys to this Hash.
source
share