class HashDot < Hash
def method_missing(sym, arg=nil)
type = sym.to_s[-1,1]
key = sym.to_s.sub(/[=?!]$/,'').to_sym
if type == "="
self[key] = arg
return self[key]
else
return self[key]
end
end
end
So I created this minimalist class that extends hash, and it does not
segfault.
The questions are:
- how to figure out what's wrong with OpenStruct (I am not a gdb guy
but could follow instructions)
- why is the source for OpenStruct and OpenObject so complicated
(compared to HashDot)?
They both remove as many Kernel methods as they possibly can in order
to make the objects as "open" as possible. So my guess is, this must
be arising from a method that Ruby is expecting to exist (as public)
but that both classes are clobbering. The question then is which one.
To help out this is what OpenObject does.
class HashDot < Hash
def method_missing(sym, arg=nil)
type = sym.to_s[-1,1]
key = sym.to_s.sub(/[=?!]$/,'').to_sym
if type == "="
self[key] = arg
return self[key]
else
return self[key]
end
end
end
So I created this minimalist class that extends hash, and it does not
segfault.
The questions are:
- how to figure out what's wrong with OpenStruct (I am not a gdb guy
but could follow instructions)
- why is the source for OpenStruct and OpenObject so complicated
(compared to HashDot)?