Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

Pick for selecting part of object attributes #38

Closed
wants to merge 2 commits into from
Closed

Pick for selecting part of object attributes #38

wants to merge 2 commits into from

Conversation

santervo
Copy link

Hey Hay

I've been using Stapes as a view model layer for Rivets.js, and Backbone as persistence layer.

In the view model layer I have both data that is going to be persisted (form data) and transient view attributes (such as whether todo entry is editable or not).

I've been missing a function similar to .pick in Underscore and Backbone to select only persistable attributes.

module.set({
  title: "Wash dishes",
  completed: true,
  editable: true
});

var persistableAttrs = module.pick('title', 'completed');
// { title: "Wash dishes", completed: true }

If you care to include this to Stapes, you'll find tests, documentation and implementation with this pull request.

hay added a commit that referenced this pull request Nov 6, 2013
@hay
Copy link
Owner

hay commented Nov 6, 2013

Thanks for the PR! I like the functionality and i have included it in commit 60c0799, however it's not a new method but part of the existing get method.

@hay hay closed this Nov 6, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants