Top.Mail.Ru
? ?
Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Thursday, June 1st, 2006

Time Event
10:14a
DRY Accessor Helper
I got tired of creating accessor methods for properties (as well as the properties themselves!) in my javascript classes, so, taking a note from the prototype.js library, I wrote a helper which acts a little like ruby's attr_writer and attr_reader as well as method_missing. It's loosely based upon a MockObject class written by William Tayson at http://www.jadetower.org/muses/archives/000388.html. The library itself does not have any dependencies, although I am (for convenience sake) using it with the prototype.js Object.extend() function in the example which follows. Code followsCollapse ) Here's test code, showing usage..... test codeCollapse ) I'll have this shortly posted to CVS, but what do you think?

<< Previous Day 2006/06/01
[Calendar]
Next Day >>
About LiveJournal.com
Image