Domain modelling and ActiveRecords

Hi all,

I am wondering if this could be a good idea to support the Object#extend
method for an ActiveRecord class.

Let’s say I have a customer (with a corresponding customer table in the
DB). At one point, this customer becomes a “BillableCustomer” (with data
in another table for billing information).

Wouldn’t it be nice to write:

customer.extend(Billable)
customer.billingAddress = …
customer.save

This way, you could implement Actor-Role patterns without the necessity
to create 2 classes representing the same logical object and an
association between the 2.

What do you think? Have you ever encountered that need? How did you deal
with it?

Thanks,

Eric.


Eric T.
LTG - Product Manager
LEIRIOS
tel: 33(0)6.61.48.57.65/33(0)3.81.88.62.02
e-mail: [email protected]
blog: http://etorreborre.blogspot.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs