Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed; 'path' is now a valid pathname

closes #356
  • Loading branch information...
commit 73fda8d7da3dd8537288ac4767381fa828fd8d57 1 parent a05e794
Aaron Heckmann authored May 20, 2011
16  lib/mongoose/document.js
@@ -194,6 +194,7 @@ Document.prototype.set = function (path, val, type) {
194 194
     adhocs = this._adhocPaths || (this._adhocPaths = {});
195 195
     adhocs[path] = Schema.interpretAsType(path, type);
196 196
   }
  197
+
197 198
   if ('string' !== typeof path) {
198 199
 
199 200
     if (null === path || undefined === path)
@@ -213,7 +214,7 @@ Document.prototype.set = function (path, val, type) {
213 214
 
214 215
     while (i--) {
215 216
       key = keys[i];
216  
-      if (!(this.path(prefix + key) instanceof MixedSchema)
  217
+      if (!(this._path(prefix + key) instanceof MixedSchema)
217 218
         && undefined !== path[key]
218 219
         && null !== path[key]
219 220
         && Object == path[key].constructor) {
@@ -226,7 +227,7 @@ Document.prototype.set = function (path, val, type) {
226 227
     return this;
227 228
   }
228 229
 
229  
-  var schema = this.path(path)
  230
+  var schema = this._path(path)
230 231
     , parts = path.split('.')
231 232
     , obj = this.doc
232 233
     , self = this;
@@ -365,7 +366,7 @@ Document.prototype.get = function (path, type) {
365 366
     adhocs[path] = Schema.interpretAsType(path, type);
366 367
   }
367 368
   var obj
368  
-    , schema = this.path(path) || this.schema.virtualpath(path)
  369
+    , schema = this._path(path) || this.schema.virtualpath(path)
369 370
     , adhocs
370 371
     , pieces = path.split('.');
371 372
 
@@ -386,8 +387,10 @@ Document.prototype.get = function (path, type) {
386 387
  * in the schema's list of type schemas
387 388
  * @param {String} path
388 389
  * @param {Object} obj
  390
+ * @api private
389 391
  */
390  
-Document.prototype.path = function (path, obj) {
  392
+
  393
+Document.prototype._path = function (path, obj) {
391 394
   var adhocs = this._adhocPaths
392 395
     , adhocType = adhocs && adhocs[path];
393 396
   if (adhocType) {
@@ -397,7 +400,6 @@ Document.prototype.path = function (path, obj) {
397 400
   }
398 401
 };
399 402
 
400  
-
401 403
 /**
402 404
  * Commits a path, marking as modified if needed. Useful for mixed keys
403 405
  *
@@ -473,8 +475,8 @@ Document.prototype.isModified = function (path) {
473 475
  *       that we want to send to MongoDB on a Document save.
474 476
  *
475 477
  * @param {String} path
476  
- *
477 478
  */
  479
+
478 480
 Document.prototype.isDirectModified = function (path) {
479 481
   return (path in this.activePaths.states.modify);
480 482
 };
@@ -704,13 +706,13 @@ Document.prototype.inspect = function () {
704 706
   return inspect(this.doc);
705 707
 };
706 708
 
707  
-
708 709
 /**
709 710
  * Returns true if the Document stores the same data as doc.
710 711
  * @param {Document} doc to compare to
711 712
  * @return {Boolean}
712 713
  * @api public
713 714
  */
  715
+
714 716
 Document.prototype.equals = function (doc) {
715 717
   return this.get('_id') === doc.get('_id');
716 718
 };
2  lib/mongoose/model.js
@@ -81,7 +81,7 @@ Model.prototype.save = function (fn) {
81 81
   var dirty = this.activePaths.map('modify', function (path) {
82 82
     return { path: path
83 83
            , value: self.getValue(path)
84  
-           , schema: self.path(path) };
  84
+           , schema: self._path(path) };
85 85
   }); 
86 86
 
87 87
   if (this.isNew) {
6  test/schema.onthefly.test.js
@@ -34,11 +34,11 @@ module.exports = {
34 34
 
35 35
     var postOne = new Decorated();
36 36
     postOne.set('adhoc', '9', Number);
37  
-    postOne.path('adhoc').should.not.equal(undefined);
  37
+    postOne._path('adhoc').should.not.equal(undefined);
38 38
 
39 39
     var postTwo = new Decorated();
40  
-    postTwo.path('title').should.not.equal(undefined);
41  
-    should.strictEqual(undefined, postTwo.path('adhoc'));
  40
+    postTwo._path('title').should.not.equal(undefined);
  41
+    should.strictEqual(undefined, postTwo._path('adhoc'));
42 42
     db.close();
43 43
   },
44 44
 

0 notes on commit 73fda8d

Please sign in to comment.
Something went wrong with that request. Please try again.