Comparing version 0.3.4 to 0.3.5
{ | ||
"name": "brink", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./src/brink/brink.js", |
@@ -115,3 +115,2 @@ $b( | ||
/*********************************************************************** | ||
@@ -118,0 +117,0 @@ Saves a record in your persistence layer. |
@@ -28,2 +28,18 @@ $b( | ||
get : function (key) { | ||
var val; | ||
if (typeof this.__meta.data[key] === 'undefined') { | ||
if (typeof options.defaultValue !== 'undefined') { | ||
val = options.defaultValue; | ||
} | ||
else { | ||
val = $b.__models[mKey].create(); | ||
} | ||
this.__meta.data[key] = val; | ||
} | ||
return this.__meta.data[key]; | ||
@@ -117,3 +133,5 @@ }, | ||
val = val.serialize(filter); | ||
} else { | ||
} | ||
else { | ||
val = get(val, 'pk'); | ||
@@ -127,3 +145,2 @@ } | ||
} | ||
}, | ||
@@ -141,2 +158,3 @@ | ||
if (options.embedded) { | ||
record = get(this, key) || $b.__models[mKey].create(); | ||
@@ -143,0 +161,0 @@ |
@@ -206,3 +206,2 @@ /*********************************************************************** | ||
/*********************************************************************** | ||
@@ -221,3 +220,2 @@ Whether or not the record has one or more changed properties since the | ||
/*********************************************************************** | ||
@@ -247,3 +245,2 @@ Opposite of isDirty. | ||
/*********************************************************************** | ||
@@ -554,3 +551,2 @@ Get the primary key value of the record. | ||
/*********************************************************************** | ||
@@ -557,0 +553,0 @@ Reverts all changes made to this record since the last save() or fetch(). |
@@ -38,3 +38,2 @@ $b( | ||
/*********************************************************************** | ||
@@ -339,3 +338,3 @@ Clear the store. Removes all record instances in the store. | ||
/*********************************************************************** | ||
/*********************************************************************** | ||
Given a modelKey or collectionKey returns the corresponding Model Class. | ||
@@ -342,0 +341,0 @@ |
@@ -232,3 +232,4 @@ describe('belongsTo', function () { | ||
light : $b.belongsTo('light', {embedded : true}), | ||
linkedTo : $b.belongsTo('light', {embedded: true, readOnly : true}) | ||
linkedTo : $b.belongsTo('light', {embedded: true, readOnly : true}), | ||
linkedToNull : $b.belongsTo('light', {embedded: true, defaultValue : null}) | ||
}), | ||
@@ -255,3 +256,4 @@ | ||
switchInstance.flip(); | ||
expect(switchInstance.linkedTo).to.equal(undefined); | ||
expect(switchInstance.linkedTo).to.be.an.instanceOf(Light); | ||
expect(switchInstance.linkedToNull).to.equal(null); | ||
switchInstance.linkedTo = Light.create({voltage: 345}); | ||
@@ -270,3 +272,4 @@ | ||
voltage: 345 | ||
} | ||
}, | ||
linkedToNull : null | ||
}); | ||
@@ -273,0 +276,0 @@ |
990295
21135