component / model

Minimalistic extensible data models
122 stars 40 forks source link

changed #toJSON to return a copy #39

Closed ianstormtaylor closed 11 years ago

ianstormtaylor commented 11 years ago

toJSON is often used before passing the attrs to another party, and you don't want them accidentally editing them out from under your models

tj commented 11 years ago

should be fine though since they'd be converted to json right away

tj commented 11 years ago

(assuming .toJSON() isn't used for anything else)

ianstormtaylor commented 11 years ago

gah i had a use case that made sense the other day and now i forgot it. i'll be back ;)

amasad commented 10 years ago

Wondering why haven't this made it in. It's often the case that you want to add and change stuff on the toJSON'd model before passing it to a template and it's counter intuitive to have the original model reflect those changes.