[Newbies] Equiv. ruby's method_missing

Bakki Kudva bakki.kudva at gmail.com
Wed Aug 23 15:23:36 UTC 2006


Hi all,

Rail's Activerecord uses Ruby's method_missing to implement dynamic
finders such as find_by_#column_name()

which is done by defining in the receiver...
def method_missing(method_id, *arguments)
     if match = /find_(all_by|by)_([_a-zA-Z]\w*)/.match(method_id.to_s)
        finder, deprecated_finder = determine_finder(match),

determine_deprecated_finder(match)
       attribute_names = extract_attribute_names_from_match(match)
       super unless all_attributes_exists?(attribute_names)
<snip>

Does Smalltalk have some way of emulating this?
I am reading Smalltalk-80 books and don't see anything there. Is the
current language support such callback hooks (and others which trap
object create events and such?)

I was inspired to study this when I read an old thread (2005) on the
seaside list about writing an activerecord like layer for
Seaside...although GLORP may be a better option in the long run. This
is pretty much an academic excercise for me now.

THanks for your help,

bakki


More information about the Beginners mailing list