zerosum dirt(nap)

evolution through a series of accidents

zerosum dirt(nap)

DataMapper 0.2.5 Released

December 21, 2007 by nap · Comments

Sam released DataMapper 0.2.5 on Wednesday. It includes a bunch of tasty bugfixes before our next leap to 0.3.×. Give it a try if you haven’t, I think you’ll like it. And if you don’t, well, you’re… whatever.

One of the changes that I’m particularly fond of is proper method visibility for properties:

class Person < DataMapper::Base
  property :ssn, :private => true
  property :login, :protected => true
  property :name
  property :address

  has_many :dogs
  belongs_to :alien_overlord
end

The private and protected options are really just shortcuts for (`:reader => :public, :writer => :private`) and (`:reader => :public, :writer => :protected`), respectively. In most cases you’ll want your reader to be public, but if you want to apply the same visibility modifier to both reader and writer, there’s an ‘:accessor’ option too. The property visibility is respected for mass assignment, which is a nice natural way to do things imo, unlike the hacky attr_protected stuff in ActiveRecord, which never felt right to me.

In any case, we’ve also updated the Website and Getting Started page, which was a little out of date. See those links for installation instructions and feel free to pop into the `#datamapper` channel on IRC, hit up the mailing list, or even leave blog comments here if you have any issues.

Other important changes (see the changelog for a complete list):

  • `MyModel#[]` only accepts a primary key now, not an options hash (use first, all)
  • `database.get` (equivalent to AR’s `find_by_id`) is approximately 25% faster than before!
  • Persistence module added (you no longer have to inherit from DM::Base, although I still prefer this approach)
  • You can now set indexes with `:index => true` and `:index => :unique`
  • Validatable gem now used for handling validations
blog comments powered by Disqus