datamapper – Tea-Driven Development https://blog.mattwynne.net Matt Wynne taking it one tea at a time Wed, 21 Aug 2019 13:05:19 +0000 en-US hourly 1 https://wordpress.org/?v=6.2 165828820 DataMapper: A Better ORM for Ruby https://blog.mattwynne.net/2008/05/23/datamapper-a-better-orm-for-ruby/ https://blog.mattwynne.net/2008/05/23/datamapper-a-better-orm-for-ruby/#comments Fri, 23 May 2008 07:11:36 +0000 http://blog.mattwynne.net/2008/05/23/datamapper-a-better-orm-for-ruby/ Continue reading "DataMapper: A Better ORM for Ruby"

]]>
One of the things that’s always irritated my about rails’ ActiveRecord framework is the way that the domain model lives in the database.Don’t get me wrong: it’s very clever, and a great showcase for ruby’s metaprogramming features, which will blow average C# / Java mind the mind when they first see it.

In rails, you build a database of your domain model, and create empty classes with the names of the domain entities (conventionally the singular of a database table name) which inherit from ActiveRecord. ActiveRecord then looks at your database, and using the magic of metaprogramming, hydrates your object with a bunch of properties that map to the database fields.

But I prefer to write my models in the code, and if you do too, you might want to take a look at DataMapper.

]]>
https://blog.mattwynne.net/2008/05/23/datamapper-a-better-orm-for-ruby/feed/ 3 64