Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created August 4, 2009 13:58
Show Gist options
  • Select an option

  • Save brandon-beacher/161250 to your computer and use it in GitHub Desktop.

Select an option

Save brandon-beacher/161250 to your computer and use it in GitHub Desktop.
var DavFolder = new Resource('davFolder', {
"@save": function() {
throw "what happens if I throw during a save?";
}
});
DavFolder.root = function() {
davFolders = DavFolder.search({ parentId: null, name: "/" });
switch (davFolders.length) {
case 0:
var davFolder = new DavFolder();
davFolder.parentId = null;
davFolder.name = "/";
davFolder.save();
return davFolder;
break;
case 1:
return davFolders[0];
break;
default:
return "barf";
//throw "Got an unexpected number of root folders.";
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment