[Newbies] Ruby macros
ramon.leon at allresnet.com
Mon Jul 3 17:15:38 UTC 2006
> -----Original Message-----
> From: beginners-bounces at lists.squeakfoundation.org
> [mailto:beginners-bounces at lists.squeakfoundation.org] On
> Behalf Of itsme213
> Sent: Saturday, July 01, 2006 9:33 PM
> To: squeak-beginers
> Subject: [Newbies] Ruby macros
> I miss my Ruby macros (1st day in Squeak and I love it ...
> dislike the camelCase tho'). Would this be the correct way to
> go about it?
> class Class
> def has_many symbol
> ...generate getter/setter with Collection.new
> class House
> has_many :doors # just remove this line to "Undo" !
Correct me if I'm wrong, but those Ruby macro's don't actually generate
getters and setters, rather, don't they just setup method_missing to
intercept those calls as if getters and setters actually existed? Don't the
relationships in ActiveRecord do this as well? If so, method_missing is the
same as Smalltalk's doesNotUnderstand:, so you can accomplish the same thing
in Smalltalk by overriding new on the class side and implementing methods
like hasOne: and hasMany: to setup a property hash in the object that
doesNotUnderstand: can check to handle messages. As a newbie, I doubt
you're ready for hacking doesNotUnderstand:, yet, but it's certainly
possible to implement declarative relationships, quite easily in fact.
More information about the Beginners