Here's one approach: Labour = Class.create(); Labour.prototype = { initialize: function(name) { this.name = name; }, showMeYourName: function() { alert(this.name); } } Worker = Class.create(); Worker.prototype = Object.extend(Labour.prototype, { initialize: function(name, position) { this.name = name; this.position = position; }, showMeYourPosition: function() { alert(this.position); } }); var labour = new Labour('Bob'); labour.showMeYourName(); var worker = new Worker('Joe', 'Boss'); // call "base" class method worker.showMeYourName(); // ... and invoke new Worker class method worker.showMeYourPosition(); This just replaces the existing initialize with a derived version. There's no provision to call Labour.initialize in Worker.initialize. You do get everything else though... Cliff On Dec 24, 2005, at 14:49, QnA wrote:
|
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs