Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Class = function(){
- var klass = function(){
- this.init.apply(this, arguments);
- };
- klass.prototype.init = function(){};
- // Shortcut to access prototype
- klass.fn = klass.prototype;
- // Shortcut to access class
- klass.fn.parent = klass;
- // Adding class properties
- klass.extend = function(obj){
- var extended = obj.extended;
- for(var i in obj) {
- klass[i] = obj[i];
- }
- if (extended) extended(obj)
- };
- // Adding instance properties
- klass.include = function(obj) {
- var included = obj.included;
- for (var i in obj) {
- klass.fn[i] = obj[i];
- }
- if (included) included(klass)
- };
- return klass;
- };
Add Comment
Please, Sign In to add comment