From: Clifford Heath Date: 2007-03-19T09:10:05+09:00 Subject: Re: attr_accessor David A. Black wrote: > Wouldn't it be better to call that checked_attr? I'm just thinking > that it's mostly checking the class, rather than the type You have the choice of using class checking or block-based checking, which can perform whatever type checks are relevant, including respond_to? and related checks. The parameter list consists of a list of any of four kinds of things: * a Class (which is used for subsequent class checks), * nil (indicating that nil values are allowed), * a Symbol, which creates an attribute having the defined checks, * any other value, which is used as a default value. The block, if any, is applied to all created attributes. Class checking is just a shorthand limited form of type checking. I'm fully aware if the distinction, but this method encourages type checking, not just class checking, so I think it's correctly named. The gem also contains "array_attr", which creates a subclass of Array that overrides every mutating method of Array to provide the same checking for array attributes as well (with the exception of nil and default values). Take a look at the RDoc for more info. Clifford Heath.