Comparing version 0.0.4 to 0.0.5
18
model.js
@@ -18,2 +18,4 @@ var Emitter = require('emitter'); | ||
var id_param = opt.id || 'id'; | ||
var Construct = function(initial) { | ||
@@ -35,3 +37,3 @@ if (!(this instanceof Construct)) { | ||
if (initial) { | ||
self.id = initial.id; | ||
self[id_param] = initial[id_param]; | ||
} | ||
@@ -52,3 +54,3 @@ | ||
return self.url_root + '/' + self.id; | ||
return self.url_root + '/' + self[id_param]; | ||
}, | ||
@@ -218,4 +220,4 @@ set: function(val) { | ||
if (self.id) { | ||
obj['id'] = self.id; | ||
if (self[id_param]) { | ||
obj[id_param] = self[id_param]; | ||
} | ||
@@ -243,3 +245,3 @@ | ||
var self = this; | ||
return !self.id; | ||
return !self[id_param]; | ||
}; | ||
@@ -276,3 +278,3 @@ | ||
if (is_new) { | ||
self.id = result.id; | ||
self[id_param] = result[id_param]; | ||
} | ||
@@ -288,3 +290,3 @@ | ||
// nothing to fetch if we don't have an id | ||
if (!self.id) { | ||
if (!self[id_param]) { | ||
return; | ||
@@ -294,3 +296,3 @@ } | ||
var sync_opt = { | ||
url: self.url_root + '/' + self.id, | ||
url: self.url_root + '/' + self[id_param], | ||
method: 'GET' | ||
@@ -297,0 +299,0 @@ }; |
{ | ||
"name": "bamboo", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Roman Shtylman <shtylman@gmail.com>", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
34747
908