dblack / wobblini.net wrote:
> I guess my first take on it would be this:
> (using define_method rather than def so that the local variable block
> will still be in scope).

Excellent! I added the missing instance_variable_set and I'm away.
My full example has type checking, and whether nil is allowed.
Oh, and type-checked array attributes in the same fashion.
Will post soon... or is there an existing package to add this to?

class Foo
    MAX = 14
    typed_attr Integer, nil, :foo {|v| v <= MAX }
    array_attr Range, :bar {|v| v.end+(v.exclude_end? ? 0 : 1) < MAX }
end

Clifford Heath.