Permalink
Browse files

[fix] [minor] Make sure to still attach non-schema methods onto Resou…

…rce.
  • Loading branch information...
Marak committed Sep 7, 2012
1 parent 8fc0486 commit 67f63f9541d409e7efb7404f3e1818ca6ae66fce
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/resourceful/resource.js
@@ -732,8 +732,6 @@ Resource.method = function (name, fn, schema) {
this[name] = function(){
var args = utile.args(arguments);
var payload = {};
-
-
//
// Compare parsed arguments to expected schema
//
@@ -748,7 +746,6 @@ Resource.method = function (name, fn, schema) {
}
});
});
-
//
// TODO: better default settings using new(that)(payload) instance
//
@@ -758,7 +755,9 @@ Resource.method = function (name, fn, schema) {
}
});
- // turn payload back into args
+ //
+ // Turn payload back into args
+ //
var _args = [];
Object.keys(payload).forEach(function(val){
_args.push(payload[val]); // ignore the key, assume order of arguments is 1:1 to schema property declarations
@@ -785,9 +784,9 @@ Resource.method = function (name, fn, schema) {
return fn.apply(this, _args);
}
};
+ } else { // no schema present, pass along the function un-altered
+ this[name] = fn;
}
-
- this[name] = fn;
this[name].type = "method";
this[name].schema = schema;
if(typeof this.methods === "undefined") {

0 comments on commit 67f63f9

Please sign in to comment.