solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 229 forks source link

The ability to build a new Attribute instance based on an exsiting Attribute #175

Closed fredwu closed 10 years ago

fredwu commented 11 years ago

Hi,

Whilst developing Datamappify, I need to 'mutate' a few Virtus::Attribute instances - basically change their name.

In Virtus 0.5.x I did the evil thing of changing Virtus::Attribute's internel state. In 1.0 however, this is no longer possible.

During the context of mutating Attribute objects, I have no access to the attribute DSL provided by Virtus::Extensions, but I do have access to AttributeSet. Therefore, I need a way to either reconstruct a new Attribute instance based on extracted values (name, type and options) from an existing Attribute, or to "clone" an Attribute and then change its name.

Any ideas of how I could accomplish this? :)

Thanks!

solnic commented 10 years ago

I'm gonna close this since it's now possible to rebuild an attribute (again).