On Thu, Mar 13, 2008 at 04:04:57AM +0900, Ed Hames wrote:
> Dear rubyists,
>
> What's the best way to get the list of attributes of an OpenStruct?
Not perfect, but this might do the trick:
>> require 'ostruct'
=> true
>> x = OpenStruct.new(:foo => 'asdf')
=> #<OpenStruct foo="asdf">
>> x.methods - OpenStruct.instance_methods
=> ["foo", "foo="]
>>
--
Aaron Patterson
http://tenderlovemaking.com/