I'm a little bit confused by this code. Is the goal here something like this:

metadata_section = @metadata
attr.split("/").each do |part|
    metadata_section[part] ||= Mash.new
    metadata_section = metadata_section[part]
end