Good point. I haven't yet ran into a need for that in my scripts thus I haven't considered that case.
-B On Oct 19, 8:05 am, "Richard Quadling" <[EMAIL PROTECTED]> wrote: > On 19/10/2007, Bart Lewis <[EMAIL PROTECTED]> wrote: > > > > > > > I wrote this little script yesterday and was very happy with it and > > wanted to share. Hopefully someone else out there finds it useful. > > > Usually when I write classes (Prototype 1.6) I use what I think is a > > pretty common method for defining defaults and allowing those defaults > > to be overridden. It looks something like this: > > >http://pastie.caboo.se/108865 > > (Section 1) > > > This simply and quick solution usually does the job. But notice how > > the "defaults" object has an object within it called "feedback". This > > object holds 3 items called "tryAgain", "correct", and "incorrect". > > What if you want to override the "correct" item but leave the > > "tryAgain" and "incorrect" intact? The standard "Object.extend" method > > isn't going to help us here. Setting only the "feedback.correct" will > > in fact leave you with no "feedback.tryAgain" or "feedback.incorrect" > > properties at all. They'll be overridden and lost. > > >http://pastie.caboo.se/108865 > > (Section 2) > > > My solution was to write a mixin that would recursively look at the > > passed in properties and only replace the exact nodes specified. For > > example, now we can override the "correct" item AND leave the > > "tryAgain" and "incorrect" intact! > > >http://pastie.caboo.se/108865 > > (Section 3) > > > I tried to write this mixin in such may that it could be used on just > > about any Class. I have not extensively tested it but it's holding up > > so far in all of my cases. > > The contra question to this would be how do I NOT merge my subclass > options but override them. Maybe only merge some and not others? > > -- > ----- > Richard Quadling > Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---
