Hey Peter, Yes, the EmbeddedValue pattern is something that's coming down the pipe i believe (it's also a feature i need, and i've done some pretty crazy hacking to get around it).
What i've done to compensate is actually write a query system on top of DataMapper. I've patched Left Outer Joins into datamapper (which i really should provide as a patch somewhere), and connected my primary object to a bunch of child objects through has n relationships. That way you can query your primary objects w/ conditions on any (optional) child objects and the rest of DM's machinery lets you maintain the objects and specify them in a relatively painless manner. Hope that helps some, -Ted On Thu, Jul 29, 2010 at 3:09 AM, Peter Mylemans <[email protected]>wrote: > Hi, > > I've been looking at your datamapper solution and it's been coming > along great. However I've got an issue with "value objects". (I'm > using a Domain Driven Design approach) > > Basically these are objects that have no identity but allow you to > encapsulate some properties with application logic like validation, > custom methods... An example: > class Employee: > property :id, Serial > property :name, String, :required => true > property :employment, Period, :required => true > end > > class Period: > # should act as a value object > property :start, Date, :required => true > property :end, Date, :required => true > > # specific period validation constraints like "end after start", ... > end > > I think that all I need is some way to create composed properties > (that are basically a set of other properties). In ActiveRecord I > could simulate this behaviour by using composed_of in combination with > validates_associated. > > I've looked at custom types, but they seem to cover only one column in > the database. Is a feature like this implemented or planned? Could I > create this behaviour with a custom plugin? > > Thanks for your advice in this matter! > > Peter > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<datamapper%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
