> On 2/19/06, George Ogata <g_ogata / optushome.com.au> 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