Rebuilding of ActiveRecord using Ruby with embedded SQL and metaprogramming (send/define_method) techniques