Created
April 1, 2013 21:20
-
-
Save rgrove/5287853 to your computer and use it in GitHub Desktop.
Super fast read-only fake Y.Model instance.
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
// Super fast read-only fake Model. | |
var GlobalEnv = YUI.namespace('Env.Model'); | |
function LazyModel(config) { | |
this.data = Y.merge(config); | |
this.data.clientId || (this.data.clientId = this.generateClientId()); | |
this.lists = []; | |
} | |
LazyModel.prototype = { | |
_isYUIModel: true, | |
addTarget: function () { | |
// noop | |
}, | |
generateClientId: function () { | |
GlobalEnv.lastId || (GlobalEnv.lastId = 0); | |
return 'lazyModel' + '_' + (GlobalEnv.lastId += 1); | |
}, | |
get: function (name) { | |
return this.data[name]; | |
}, | |
getAttrs: function () { | |
return Y.merge(this.data); | |
}, | |
removeTarget: function () { | |
// noop | |
} | |
}; | |
Y.LazyModel = LazyModel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment