Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11122 (new enhancement)

Opened 2 years ago

Last modified 2 years ago

[PATCH] add support for alternative constructors for composed_of value objects

Reported by: cch1 Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: composed_of aggregation value constructor
Cc:

Description

The composed_of macro assumes that the value object can be instantiated with new. But for some aggregate classes, new is not the appropriate constructor and instead something like parse is required.

This patch adds support for a :constructor option to the composed_of method. It accepts a symbol identifying a constructor method on the aggregate class. All aggregate object are then instantiated using this constructor method.

Of course, the default value for the constructor is :new.

Attachments

11122.diff (5.1 kB) - added by cch1 on 02/15/08 02:18:22.
Patch with documentation and tests.
11122.2.diff (5.1 kB) - added by cch1 on 02/15/08 02:23:07.

Change History

02/15/08 02:18:22 changed by cch1

  • attachment 11122.diff added.

Patch with documentation and tests.

02/15/08 02:23:07 changed by cch1

  • attachment 11122.2.diff added.

02/15/08 02:33:06 changed by cch1

The two files are identical with the possible exception of line terminators. Wrestling with the *&%$#* diff program on Windows...