Skip to content

Instantly share code, notes, and snippets.

@hjdivad
Created January 19, 2014 22:00
Show Gist options
  • Save hjdivad/8511551 to your computer and use it in GitHub Desktop.
Save hjdivad/8511551 to your computer and use it in GitHub Desktop.
and = Ember.computed.and;
equal = Ember.computed.equal;
bool = Ember.computed.bool;

Ember.Object.extend({
  isHeirToCasterlyRock: and(equal('lastName', 'Lannister'),
                            bool('isEldestSon')),  // Primogeniture is actually
                                                  // more complicated but w/e

  isCersei: and(equal('lastName', 'Lannister'),
                equal('gender', 'female'))

})

There will actually be two implicit computed properties for equal('lastName', 'Lannister') although in principle this could be optimised to only one (and if people did this manually they would have only one property: isLannister).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment