I’m writing a bunch of auto-marshaling code to let CLR code call back
Ruby. I just got the simplest possible marshaling scenario working
which is letting you bind an Array of ActiveRecord objects to a CLR
DataGridView control. See
a longer discussion and a screenshot.
Bottom line is that I can now write:
data_grid.data_source = Person.find_by_last_name(‘Lam’)
Now, here’s my problem: I’m not all that happy that I’m special casing
code for ActiveRecord objects. However, since Ruby doesn’t have a
for runtime-discovery of attributes, I’m special casing for ActiveRecord
since it provides an @attributes hashtable with the name-value pairs for
attributes in the object. This makes it easy for me to generate the CLR
anonymous class + object that implements the marshaling code that
the attribute data from the Ruby ActiveRecord object (think about this
marshal by reference).
Do folks have suggestions for implementing a discoverable attribute /
property idiom in Ruby? Perhaps via a mixin module in the standard
Or has this been done already and I’m just showing my Ruby newbiness?