Pick for selecting part of object attributes #38

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@santervo

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 hay added a commit that referenced this pull request Nov 6, 2013
@hay Adding 'pick' like functionality to get() (issue #38) 60c0799
@hay
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 join this conversation on GitHub. Already have an account? Sign in to comment