Hacker News new | ask | show | jobs
by vidarh 1482 days ago
An added advantage of this approach is that it allows clean integration w/any other mapper or library. E.g. you could define a mapping to your Sequel or ActiveRecord models, and in one go you have the ability to roundtrip between JSON/XML etc. and the ORM.

To the point of rewriting: A halfway point is to drop inheritance in favour of include/extend'ing the models. If that's done cautiously, it allows for co-existing with model objects from libraries that require inheritance. That is, this:

   class Person
     include Shale::Mapper
   end
is preferable to

  class Person < Shale::Mapper
  end