Permalink
Browse files

Add third argument `temp` to nohm.model(). If set to true the model d…

…efinition will not be stored and cannot be used with nohm.factory().
  • Loading branch information...
1 parent 4a9692a commit bc216edc2d2ecf1a9a539269940b18b245b40efb @maritz committed Jul 13, 2012
Showing with 23 additions and 2 deletions.
  1. +4 −2 lib/nohm.js
  2. +19 −0 test/featureTests.js
View
@@ -50,7 +50,7 @@ var models = {};
* @param {Object} Option This is an object containing the actual model definitions. These are: properties, methods (optional) and the client (optional) to be used.
* @static
*/
-Nohm.model = function (name, options) {
+Nohm.model = function (name, options, temp) {
if ( ! name ) {
this.logError('When creating a new model you have to provide a name!');
}
@@ -92,7 +92,9 @@ Nohm.model = function (name, options) {
instance.remove(cb);
};
- models[name] = obj;
+ if ( ! temp) {
+ models[name] = obj;
+ }
return obj;
};
View
@@ -956,3 +956,22 @@ exports["no key left behind"] = function (t) {
}
);
};
+
+exports["temporary model definitions"] = function (t) {
+ t.expect(2);
+ var user = nohm.factory('UserMockup');
+ var user2 = nohm.factory('UserMockup');
+
+ var TempUserMockup = nohm.model('UserMockup', {
+ properties: {
+ well_shit: {
+ type: 'string'
+ }
+ }
+ }, true);
+ var new_user = new TempUserMockup();
+
+ t.deepEqual(user.allProperties(), user2.allProperties(), 'HURASDASF');
+ t.notDeepEqual(user.allProperties(), new_user.allProperties(), 'HURASDASF');
+ t.done();
+};

0 comments on commit bc216ed

Please sign in to comment.