From: Sander Land Date: 2006-02-20T01:12:59+09:00 Subject: Re: [/QUIZ] metakoans.rb (#67) > On 2/19/06, George Ogata wrote: > ... > define_method("#{arg}?"){|| !send(arg).nil?} > ... what about send(arg) == false ? Here is my solution, pretty similar to the one george posted, though it doesn't support multiple attributes. class Module def attribute(a,&blk) a,val = a.to_a[0] if a.kind_of? Hash attr_accessor a define_method(a+'?') { !!send(a) } define_method(a) { if instance_variables.include?('@'+a) instance_variable_get('@'+a) else val || instance_eval(&blk) end } if val || blk end end