It probably has something to do with the fact that you are defining the getter/setter statically on the class itself, where in the second example, you are actually defining them at the instance level, which is what you want.
In your first example, I'll bet if you just do MyClass.test = "blah" it would give you your alert... You probably just need to a) do your Class.create() first, and b) then apply your getters/setters via the prototype object of the class function: var MyClass = Class.create(); MyClass.prototype.__defineGetter__("test", someFunction); ...etc... On Wed, Jul 2, 2008 at 9:52 AM, Antoine Quint <[EMAIL PROTECTED]> wrote: > > Hi Darrin, > > On Jul 2, 2008, at 16:28 , darrin wrote: > > > Interesting, first time I've seen this. The alert is actually coming > > out of Class.create call. What about this.... > > > > var MyClass = Class.create({ > > initialize: function() { > > this.__defineGetter__('test', function() { > > alert('inside getter'); > > return 'foo'; > > }); > > > > this.__defineSetter__('test', function(new_value) { > > alert('inside setter'); > > return new_value; > > }); > > } > > }); > > That works fine indeed. Do you have any idea why that is while the > previous snippet did not work? > > The reason I ask is because I personally dislike the programming style > where properties are defined inline the object passed as the parameter > to Class.create(), and I prefer to have separate "MyClass.aFunction = > function ()" calls. Do you think there is a way to get getters and > setters to work in this style? > > Thanks a lot for your help, > > Antoine > > > > -- Ryan Gahl Manager, Senior Software Engineer Nth Penguin, LLC http://www.nthpenguin.com -- WebWidgetry.com / MashupStudio.com Future Home of the World's First Complete Web Platform -- Inquire: 1-920-574-2218 Blog: http://www.someElement.com LinkedIn Profile: http://www.linkedin.com/in/ryangahl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---