One of the things I really like about ActiveRecord is using a block when I new something up...
Person.new do |p|
p.first_name = "John"
p.last_name = "Brown"
p.dob = Date.parse("5/9/1800")
end
Fortunately this behavior is extremely easy to implement outside of ActiveRecord - by stealing from ActiveRecord::Base's source code of course!
class Person
attr_accessor :first_name, :last_name, :dob
def initialize
yield self if block_given?
end
end
Not rocket surgery but now that I have written about it I'm much less likely to forget how to do it.