Reimplementation of some parts of Ruby on Rails' ActiveRecord