On Mar 15, 2008, at 1:04 PM, me wrote:

> Say, I have a class:
>
> class Event
>  attr_accessor	:a,
>                        :b,
>                        :c,
>                        :d
>
>  def initialize()
>  end
>
>  def validate
>    # validate all attributes at once here
>  end
>


# gem install fattr
# http://codeforpeople.com/lib/ruby/fattr/fattr-1.0.3/README
require 'rubygems'
require 'fattr'

class Event

   fattrs :a, :b, :c, :d

   def initialize
     fattrs.each do |fattr|
       name, value = fattr, send(fattr)
       validate name, value
   end

   def validate name, value
     case name
       ....


also see the traits lib, more heavyweight than fatter, but also  
included built-in validations

http://codeforpeople.com/lib/ruby/traits/traits-0.9.2/README

regards.


a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama