Module: Original Output

by darcyclarke

JavaScript

// Generated by CoffeeScript 1.3.3
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, v, _extend, _ref;
    eval("var " + mixin.name + " = (function(_super) {\n  __extends(" + mixin.name + ", _super);\n  function " + mixin.name + "() {\n    return " + mixin.name + ".__super__.constructor.apply(this, arguments);\n  }\n  return " + mixin.name + ";\n})(this.__super__.constructor);");
    _ref = mixin.prototype;
    for (k in _ref) {
      v = _ref[k];
      eval("" + mixin.name + ".prototype[k] = v;");
    }
    for (k in mixin) {
      v = mixin[k];
      eval("" + mixin.name + "[k] = v;");
    }
    _extend = __extends;
    return eval("_extend(this, " + mixin.name + ");");
  };
  
  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('world');
    return Foo.__super__.hello.apply(this, arguments);
  };

  return Foo;

})(Module);

foo = new Foo;
foo.hello();
console.log(foo);