working example with ExtensibleObject

This commit is contained in:
Jeena Paradies 2012-07-19 16:24:23 +02:00
parent 3ee7c197f9
commit 976bf12cbe

View file

@ -11,12 +11,18 @@ Factory.prototype.new = function () {
var module = arguments[0]; var module = arguments[0];
var o = Object.create(module.prototype, { module.prototype = new ExtensibleObject({
factory: {value: this}, factory: this,
notificationCenter: {value: this.notificationCenter} notificationCenter: this.notificationCenter
}); });
return new (o.call(arguments))(); return new (module.bind.apply(module, arguments))();
}
function ExtensibleObject(properties) {
for(var propertyName in properties) {
this[propertyName] = properties[propertyName];
}
} }
function Player(name) { function Player(name) {
@ -35,7 +41,7 @@ var factory = new Factory();
var player = factory.new(Player, "jeena"); var player = factory.new(Player, "jeena");
player.factory.new(Player, "logsol").name; player.factory.new(Player, "logsol").notificationCenter.alert("foo");
/* /*