solnic / virtus

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

Exposes accessor options #177

Closed fredwu closed 11 years ago

fredwu commented 11 years ago

Exposes options so that it can be used for say reconstructing attributes as proposed here: #175.

solnic commented 11 years ago

thanks, I'm not sure how this will be solved so I'm gonna hold off with merging this in. First I need to clean up attribute/accessor/writer/reader builders wrt option handling. Once that's done it'll be clearer to see how cloning an attribute should be implemented.

fredwu commented 11 years ago

Sounds good! eagerly awaits :)

fredwu commented 11 years ago

FYI I've found a way to rebuild the attribute for my needs: https://github.com/fredwu/datamappify/blob/6134e60695ac93814cae623832cbde76881f5a5e/lib/datamappify/entity/composable/attributes.rb#L42-L48

solnic commented 11 years ago

@fredwu still there? I removed accessor/reader/writer eventually. turned out to be an overkill leaving Attribute class completely anaemic. Current interface is very similar to how it used to be. I can help you updating datamappify to work with next beta release so don't worry :smile:

FWIW to clone an attribute you can just do this now:

attribute = Virtus::Attribute.build(String)

cloned = Virtus::Attribute.build(attribute.type, attribute.options)

I could wrap this up inside an Attribute#clone probably.

EDIT: fixed code sample

fredwu commented 11 years ago

@solnic Ah cool, I'll take a closer look once a new beta is released! :)

solnic commented 11 years ago

@fredwu awesome, do not hesitate to ping me and ask for help. I should've not released beta0 to be honest, some people asked me to do so though and I failed to say "no" :/ Sorry about that.