Created
December 19, 2013 01:38
-
-
Save SinisterMinister/8032915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('underscore'); | |
var EmberWrapper = Intaglio.wrappers.abstract.extend({ | |
init: function (object) { | |
this._object = object; | |
}, | |
unknownProperty: function (key) { | |
return this._object.get(key); | |
}, | |
setUnknownProperty: function (key, value) { | |
Ember.propertyWillChange(this, key); | |
this._object.set(key, value); | |
Ember.propertyDidChange(this, key); | |
return this; | |
}, | |
reload: function () { | |
// Get a list of the changed values | |
var currentData = this._object.getData(), | |
self = this; | |
this._object.reload().then(function (obj) { | |
var newData = obj._object.getData(), | |
changedFields = []; | |
_.each(newData, function (value, key) { | |
if (currentData[key] !== value) | |
changedFields.push(key); | |
}); | |
_.each(changedFields, function (key) { | |
Ember.propertyWillChange(self, key); | |
Ember.propertyDidChange(self, key); | |
}); | |
}); | |
} | |
}); | |
module.exports = EmberWrapper; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment