Sha256: 3df00b2fb164a6872a3201c61319699ff099dbbc9710c1056d999014a94c0a85

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

if (typeof Object.create !== "function")
    Object.create = function(o) {
      function F() {}
      F.prototype = o;
      return new F();
    };

var Klass = {
  init: function(){},

  prototype: {
    init: function(){}
  },

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

  inst: function(){
    var instance = Object.create(this.prototype);
    instance.parent = this;
    instance.init.apply(instance, arguments);
    return instance;
  },
  
  proxy: function(func){
    var thisObject = this;
    return(function(){ 
      return func.apply(thisObject, arguments); 
    });
  },
  
  include: function(obj){
    var included = obj.included || obj.setup;
    for(var i in obj)
      this.fn[i] = obj[i];
    if (included) included(this);
  },
  
  extend: function(obj){
    var extended = obj.extended || obj.setup;
    for(var i in obj)
      this[i] = obj[i];
    if (extended) extended(this);
  }
};

Klass.fn = Klass.prototype;
Klass.fn.proxy = Klass.proxy;

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
ichabod-0.0.2 examples/jasmine/klass.js
ichabod-0.0.2 examples/qunit/klass.js
ichabod-0.0.1 examples/jasmine/klass.js