(function(){var moduleFactory=function($){var module=this;$.require().script("mvc/model.service").done(function(){var exports=function(){$.Model.service.jsonRest=$.Model.service({url:"",type:".json",name:"",getSingularUrl:function(e,t){return this.singularUrl?this.singularUrl+"/"+t+this.type:this.url+this.getName(e)+"s/"+t+this.type},getPluralUrl:function(e,t){return this.pluralUrl||this.url+this.getName(e)+"s"+this.type},getName:function(e){return this.name||e.name},findAll:function(e){var t=this._service.getPluralUrl(this);$.ajax({url:t,type:"get",dataType:"json",data:e,success:this.proxy(["wrapMany",success]),error:error,fixture:!0})},getParams:function(e){var t=this.getName(this),n={};for(var r in e)n[t+"["+r+"]"]=e[r];return n},update:function(id,attrs,success,error){var params=this._service.getParams(attrs),singular=this._service.getSingularUrl(this,id),plural=this._service.getPluralUrl(this),self=this;$.ajax({url:singular,type:"put",dataType:"text",data:params,complete:function(xhr,status){if(/\w+/.test(xhr.responseText))return error(eval("("+xhr.responseText+")"));success({})},fixture:"-restUpdate"})},destroy:function(e,t,n){var r=this._service.getSingularUrl(this,e);$.ajax({url:r,type:"delete",dataType:"text",success:t,error:n,fixture:"-restDestroy"})},create:function(attrs,success,error){var params=this._service.getParams(attrs),plural=this._service.getPluralUrl(this),self=this,name=this._service.getName(this);$.ajax({url:plural,type:"post",dataType:"text",complete:function(xhr,status){status!="success"&&error(xhr,status);if(/\w+/.test(xhr.responseText)){var res=eval("("+xhr.responseText+")");if(res[name]){success(res[name]);return}return error(res)}var loc=xhr.responseText;try{loc=xhr.getResponseHeader("location")}catch(e){}if(loc){var mtcs=loc.match(/\/[^\/]*?(\w+)?$/);if(mtcs)return success({id:parseInt(mtcs[1])})}success({})},data:params,fixture:"-restCreate"})}})};exports(),module.resolveWith(exports)})};dispatch("mvc/model.service.json_rest").containing(moduleFactory).to("Foundry/2.1 Modules")})();