This is ok... but i have a question.
If i dump the hash into a YAML file, then when i load it, the
reference
is lost and there are only copies of the same values.How can I mantain that reference when I dump/load the YAML file?
You can't serialize procs (well... you can, sort of, but it's best not
to think about it).
So, you'll need to make a more specific Reference class:
class HashReference
instance_methods.each {|m| undef_method m unless /__.*__/ === m}
def initialize(hash, key)
@hash = hash
@key = key
end
def method_missing(*args, &block)
@hash[@key].send(*args, &block)
end
end
Since this doesn't store a proc, it can be serialized.
···
#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by NetIQ MailMarshal
#####################################################################################