Russell Fulton wrote:
> In the snippet of code below hosts holds a set of class instances for
> each host in a monitoring program.  There are some special host that are
> default entries for unix, windows and other types of systems.
>
> We get the name of the machine to be monitored into $mach and see if we
> have an entry for it, if we don't then we use one of the defaults.
>
>
>
>      if ! host then
> 	if type = type_of_host( filename ) then
> 	  host = hosts[mach] =  hosts[ "default-#{type}"].clone
> 	else
> 	  host = hosts[mach] = hosts[ "default"].clone
> 	end
> 	host.name = mach
>       end
>
> I have tried both dup and clone to copy the default objects but I always
> seem to end up with the original object in host.
>
> The symptom is that when the second machine uses the default entry it
> gets the same copy as the first one.
>
> I have printed out host and hosts[ "default-#{type}"]:
>
>
> #<#<Class:0xb7537bc4>:0xb73e5a00>
> #<#<Class:0xb7537bc4>:0xb73e599c>
>
> Clearly I'm missing something important!
>
> Russell
>
>
>
> --
> Posted via http://www.ruby-forum.com/.


 Not sure if this is any help, but just today I found there is a way to
do a deepcopy
using Marshal

google search yields:
http://cyll.org/blog/tech/2006-05-26-noiwantthedeepcopy.html