Something pulls Psych somewhere for the YAML stuff. Psychic patches Kernel add psych_y method, which will be an alias of y . So everything has a y method:
> o = OpenStruct.new > o.method(:y) =>
AFAIK, OpenStruct uses method_missing and an internal hash to create accessors and mutators; but y already exists from this "friendly" patch to the kernel, so OpenStruct magic can't handle the y method because Psych magic is on the way. The mutator, y= , is excellent, so you can safely oy = 11 and see your 11 inside o .
You can remove y like this:
> o = OpenStruct.new > o.class_eval('undef_method :y') > oy = 11 > oy => 11
You can probably remove the method from Kernel and hope that nothing depends on this stupid alias y :
> Kernel.send(:undef_method, :y) > o = OpenStruct.new > oy = 11 > oy => 11
Or you can simply remove it from OpenStruct :
> OpenStruct.send(:undef_method, :y) > o = OpenStruct.new > oy = 11 > oy => 11
This is why many people do not like the patch of monkeys, especially the monkey correcting something fundamental, like Kernel .
source share