Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to omit computed attributes from toJSON? #2

Open
rymohr opened this issue Apr 28, 2014 · 2 comments
Open

Possible to omit computed attributes from toJSON? #2

rymohr opened this issue Apr 28, 2014 · 2 comments

Comments

@rymohr
Copy link

rymohr commented Apr 28, 2014

Since computed attributes are derived from other attributes they don't really need to be persisted. Is there an easy way to omit the computed attributes from the toJSON results?

@kdocki
Copy link
Owner

kdocki commented Apr 28, 2014

Yeah, that's a good idea.

What do you think about having a different method for the original toJSON()? As you can see here I am storing a reference to the original toJSON.

Maybe something like model._toJSON() or something? I'm open to suggestions.

@rymohr
Copy link
Author

rymohr commented Apr 28, 2014

How about overriding toJSON to accept options instead?

model.toJSON({computed: true})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants