Suggestive is a plugin designed to help get valid data for your ActiveRecord? models. To use it, you define a set of transformations to perform on your model to create valid values for an attribute. Then, when you call a dynamically-added method on an object, you will receive either the first available value those transformations produce, or nil if none of the pre-defined transformations generate a usable value.

Transformations must be passed as procs, though that allows everything from Proc.new {} and lambda {} to Symbol#to_proc declarations.

class Person < ActiveRecord::Base
  suggestions_for :username, 
    Proc.new {|model| model.first_name}, 
    Proc.new {|model| model.last_name} #, etc.
end

person = Person.new :first_name => 'Bob', :last_name => 'Sully'
username = person.suggest_username 
  # => 'Bob', if it has not yet been saved as a username, else 'Sully' if it is available, else nil

You can see the code for Suggestive here: http://trac.extendviget.com/lab/browser/trunk/plugins/suggestive