def _attach(mount_map, filter, path, mask=nil)
if (path == '/') then
path = ''
end
if (doc_pair = search(mount_map, path)) then
document, mount_path = doc_pair
if (path == mount_path) then
node = mount_map[path]
else
len = mount_path.length
subpath = path[len..-1]
node = {
:document => SubsetDocument.new(document, subpath),
:mask_list => Array.new
}
mount_map[path] = node
end
else
raise "not mounted at #{path}."
end
if (mask) then
mask_pair = node[:mask_list].find{ |m, d| m == mask }
if (mask_pair) then
document = mask_pair[1]
filter_document = FilterDocument.new(document, filter)
mask_pair[1] = filter_document
else
document = node[:document]
unless (document) then
raise "not mounted at #{path}:#{mask}."
end
filter_document = FilterDocument.new(document, filter)
node[:mask_list].unshift([ mask, filter_document ])
end
else
document = node[:document]
unless (document) then
raise "not mounted at #{path}."
end
filter_document = FilterDocument.new(document, filter)
node[:document] = filter_document
end
nil
end