Hello, I can't make my mind up over some finer points of an API design and would appreciate any feedback on my code. Hopefully this example is clear...
var A = Class.create({ initialize : function(obj){ Object.extend(this, obj) } }); var B = { method : function(){ .... } }; var C = { method: function(){ .... } }; var d = new A(B); var e = new A(C); On initialization each instance of class A is extended with methods from a separate object via Object.extend. I've chosen not to use Class#addMethods because each instance of can be extended with a different object, and therefore the prototype chain of class A should remain unaffected. So for so good. However I'm looking to use this taking advantage of Prototype's inheritance features for the extension objects. I've currently got something that looks like this... var A = Class.create({ initialize : function(obj){ Object.extend(this, obj.prototype) } }); var B = Class.create({ method : function(){ .... } }) var C = (B, { method: function($super){ $super(); } }; var d = new A(B); var e = new A(C); It works OK but feels a little clunky. To me it would make more sense to do something like this... var A = Class.create({ initialize : function(obj){ Object.extend(this, obj) } }); var B = Class.create({ method : function(){ .... } }) var C = (B, { method: function($super){ $super(); } }; var d = new A(new (B)); var e = new A(new (C)); Anybody got any strong opinions on which approach is best? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---