model.js

var Model = {

inherited: function () {},

created: function () {},

prototype: {
init: function (attrs){
if(attrs){
this.load(attrs);
}
},

load: function (attrs) {
for(var name in attrs){
this[name] = attrs[name];
}
}
},

create: function (){
var object = Object.create(this);
object.parent = this;
object.prototype = object.fn = Object.create(this.prototype);

object.created();
this.inherited(object);
return object;
},

init: function(){
var instance = Object.create(this.prototype);
instance.parent = this;
instance.init.apply(instance, arguments);
return instance;
},

find: function () {

},

extend: function (o) {
var extended = o.extended;

}

}

var Asset = Model.create();
var User = Model.create();

var user = User.init();

posted @ 2014-09-17 17:42  lanse_yan  阅读(465)  评论(0)    收藏  举报