Module: Generated Test

by darcyclarke

JavaScript

var Bar, Foo, Module, foo,
  __hasProp = {}.hasOwnProperty,
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

Module = (function() {

  function Module() {}

  Module.include = function(mixin) {
    var k, temp, v, _ref;
    temp = new Function("mixin", "return function " + mixin.name + "(){ mixin() };")(mixin);
    temp = __extends(temp, this.__super__.constructor);
    _ref = mixin.prototype;
    for (k in _ref) {
      v = _ref[k];
      temp.prototype[k] = v;
    }
    for (k in mixin) {
      v = mixin[k];
      temp[k] = v;
    }
    return __extends(this, temp);
  };

  return Module;

})();

Bar = (function() {

  function Bar() {}

  Bar.prototype.hello = function() {
    return console.log('hello');
  };

  return Bar;

})();

Foo = (function(_super) {

  __extends(Foo, _super);

  function Foo() {
    return Foo.__super__.constructor.apply(this, arguments);
  }

  Foo.include(Bar);

  Foo.prototype.hello = function() {
    console.log('TOP');
    return Foo.__super__.hello.apply(this, arguments);
  };

  return Foo;

})(Module);

foo = new Foo;

foo.hello();