Friday, March 21, 2008

Joose now has method modifies

You can now use the following method modifiers in Joose:

Class("S3", {
isa: S2,
override: {
two: function () {
this.result2 += "3"
this.SUPER();
}
},
before: {
add: function () { this.result += "5" }
}
after: {
add: function () { this.result += "7" }
},
wrap: {
add: function (original) { this.result += "8"; original(); this.result += "9" }
}
})

By using the excplicit override modifier you get access to the overridden method using this.SUPER(). This is basically the same as the wrap modifier, but it keeps the methods signature intact (wrap passes the wrapped function as the first parameter).
Post a Comment