class MessageMailer < Merb::MailController include DataMapper::Validate extend DataMapper::Validate::ClassMethods def attribute_get(sym); @params[sym] end def attribute_set(sym, val); @params[sym] = val end [:from].each { |s| class_eval " def #{s}; attribute_get(:#{s}) end def #{s}=(val); attribute_set(:#{s}, val) end " } validates_format :from, :as => :email_address def contact_form # use params[] passed to this controller to get data # read more at http://wiki.merbivore.com/pages/mailers render_mail end end #irb(main):011:0> m = MessageMailer.new(:to => 'asdf@asdf.com', :from => 'asdf@asdf.com', :subject => 'asdf') #=> #"asdf@asdf.com", :subject=>"asdf", :to=>"asdf@asdf.com"}, @_caught_content={}, @_benchmarks={}, @base_controller=nil> #irb(main):012:0> m.valid? #=> true #irb(main):013:0> m.errors #=> #