-
-
Save ninjabiscuit/1206835 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
if (typeof Object.create !== "function") | |
Object.create = function (o) { | |
function F() {} | |
F.prototype = o; | |
return new F(); | |
}; | |
var Model = { | |
prototype: { | |
init: function(){} | |
}, | |
create: function(){ | |
return Object.create(this); | |
}, | |
inst: function(){ | |
var instance = Object.create(this.prototype); | |
instance.init.apply(instance, arguments); | |
return instance; | |
} | |
}; | |
jQuery.extend(Model, { | |
find: function(){}, | |
}); | |
jQuery.extend(Model.prototype, { | |
load: function(attributes){ | |
for(var name in attributes) | |
this[name] = attributes[name]; | |
} | |
}); | |
var Asset = Model.create("Asset"); | |
Asset.prototype.init = function(){ | |
console.log('loaded') | |
}; | |
var asset = Asset.inst(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment