From: Sean O'Halpin Date: 2008-03-09T08:12:59+09:00 Subject: ANN: doodle 0.0.1 Doodle is a Ruby library and gem for simplifying the definition of Ruby classes by making attributes and their properties more declarative. Doodle is eco-friendly – it does not globally modify Object, Class or Module, nor does it pollute instances with its own instance variables (i.e. it plays nice with yaml). Future versions will try to be even more unobtrusive. It is similar to but different from libraries such as Ara Howard's attributes and traits and likewise owes something to the famous metakoans Ruby quiz. Features: * initialization o using positional arguments o with named arguments o by block * defaults * initial values * validation at attribute and class levels * conversions for attributes and classes * collectors to help in defining simple DSLs * works for classes, instances and singletons Putting all this together, you can initialize objects like this: event = Event "Festival" do date '2008-04-01' place "The muddy field" place "Beer tent" do event "Drinking" end end pp event #, @locations= [#, #], @name="Beer tent">], @name="Festival"> from a class definition like this: require 'date' require 'pp' require 'doodle' class Location < Doodle::Base has :name, :kind => String has :events, :init => [], :collect => :Event end class Event < Doodle::Base has :name, :kind => String has :date do kind Date default { Date.today } must 'be >= today' do |value| value >= Date.today end from String do |s| Date.parse(s) end end has :locations, :init => [], :collect => {:place => "Location"} end To install: $ sudo gem install doodle or C:\> gem install doodle For more info, see http://doodle.rubyforge.org/