ember-source 1.13.12 → 1.13.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26b5cf01082ab1d8865f82d6d9b57d59ffdc2e8c
4
- data.tar.gz: d967409290000c2a95580a088dd61a8e8c12c4e2
3
+ metadata.gz: aa31a4982e2e253bbad2c88c35b219049f443dd9
4
+ data.tar.gz: d93b967c42599cdfd2ad5f76713e986e319c8004
5
5
  SHA512:
6
- metadata.gz: 1a32727fa818713c1999e2bcb3fb57b9d7f33aa249aa32a7d3404355776e4259547329e54bb33b010f6149c651c3809f2c4552255b4de5e22d182d3385ea2bd7
7
- data.tar.gz: 73d853e03db86d4b88bfb741ea8637224b62974ed78c16aa8dbb8a40304e02c569a01072162b6f3a56b8c5fc976f53dd85a2b9d41ceea79eac6028cfb6c16f51
6
+ metadata.gz: 7f3ca5c7b0b70bc78654c2298ec237f756bfe7d883d252bddf37ac562c7e314f6f62a6d22fcd6070396fda7904770e8df9a91bf552dc43e96cc14d2b60957ad8
7
+ data.tar.gz: 693f7574fed20beaea45b12b107a5ac8a35053b34a4518e9f7481d4f8177d9df48addec19b4b5b0df765716628dab6018406d05032ca8a03bd85df8414de361d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.13.12
1
+ 1.13.13
@@ -5,7 +5,7 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 1.13.12
8
+ * @version 1.13.13
9
9
  */
10
10
 
11
11
  (function() {
@@ -1871,1410 +1871,1410 @@ enifed("ember-metal/chains", ["exports", "ember-metal/core", "ember-metal/proper
1871
1871
  exports.ChainNode = ChainNode;
1872
1872
  });
1873
1873
  // warn, assert, etc;
1874
- enifed("ember-metal/computed_macros", ["exports", "ember-metal/core", "ember-metal/property_get", "ember-metal/property_set", "ember-metal/computed", "ember-metal/is_empty", "ember-metal/is_none", "ember-metal/alias"], function (exports, _emberMetalCore, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalComputed, _emberMetalIs_empty, _emberMetalIs_none, _emberMetalAlias) {
1874
+ enifed("ember-metal/computed", ["exports", "ember-metal/core", "ember-metal/property_set", "ember-metal/utils", "ember-metal/expand_properties", "ember-metal/error", "ember-metal/properties", "ember-metal/property_events", "ember-metal/dependent_keys"], function (exports, _emberMetalCore, _emberMetalProperty_set, _emberMetalUtils, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) {
1875
1875
  "use strict";
1876
1876
 
1877
- exports.empty = empty;
1878
- exports.notEmpty = notEmpty;
1879
- exports.none = none;
1880
- exports.not = not;
1881
- exports.bool = bool;
1882
- exports.match = match;
1883
- exports.equal = equal;
1884
- exports.gt = gt;
1885
- exports.gte = gte;
1886
- exports.lt = lt;
1887
- exports.lte = lte;
1888
- exports.oneWay = oneWay;
1889
- exports.readOnly = readOnly;
1890
- exports.defaultTo = defaultTo;
1891
- exports.deprecatingAlias = deprecatingAlias;
1892
-
1893
1877
  /**
1894
1878
  @module ember
1895
1879
  @submodule ember-metal
1896
1880
  */
1897
1881
 
1898
- function getProperties(self, propertyNames) {
1899
- var ret = {};
1900
- for (var i = 0; i < propertyNames.length; i++) {
1901
- ret[propertyNames[i]] = _emberMetalProperty_get.get(self, propertyNames[i]);
1902
- }
1903
- return ret;
1904
- }
1905
-
1906
- function generateComputedWithProperties(macro) {
1907
- return function () {
1908
- for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
1909
- properties[_key] = arguments[_key];
1910
- }
1882
+ var metaFor = _emberMetalUtils.meta;
1911
1883
 
1912
- var computedFunc = _emberMetalComputed.computed(function () {
1913
- return macro.apply(this, [getProperties(this, properties)]);
1914
- });
1884
+ function UNDEFINED() {}
1915
1885
 
1916
- return computedFunc.property.apply(computedFunc, properties);
1917
- };
1918
- }
1886
+ // ..........................................................
1887
+ // COMPUTED PROPERTY
1888
+ //
1919
1889
 
1920
1890
  /**
1921
- A computed property that returns true if the value of the dependent
1922
- property is null, an empty string, empty array, or empty function.
1891
+ A computed property transforms an object's function into a property.
1923
1892
 
1924
- Example
1893
+ By default the function backing the computed property will only be called
1894
+ once and the result will be cached. You can specify various properties
1895
+ that your computed property depends on. This will force the cached
1896
+ result to be recomputed if the dependencies are modified.
1897
+
1898
+ In the following example we declare a computed property (by calling
1899
+ `.property()` on the fullName function) and setup the property
1900
+ dependencies (depending on firstName and lastName). The fullName function
1901
+ will be called once (regardless of how many times it is accessed) as long
1902
+ as its dependencies have not changed. Once firstName or lastName are updated
1903
+ any future calls (or anything bound) to fullName will incorporate the new
1904
+ values.
1925
1905
 
1926
1906
  ```javascript
1927
- var ToDoList = Ember.Object.extend({
1928
- isDone: Ember.computed.empty('todos')
1907
+ var Person = Ember.Object.extend({
1908
+ // these will be supplied by `create`
1909
+ firstName: null,
1910
+ lastName: null,
1911
+
1912
+ fullName: function() {
1913
+ var firstName = this.get('firstName');
1914
+ var lastName = this.get('lastName');
1915
+
1916
+ return firstName + ' ' + lastName;
1917
+ }.property('firstName', 'lastName')
1929
1918
  });
1930
1919
 
1931
- var todoList = ToDoList.create({
1932
- todos: ['Unit Test', 'Documentation', 'Release']
1920
+ var tom = Person.create({
1921
+ firstName: 'Tom',
1922
+ lastName: 'Dale'
1933
1923
  });
1934
1924
 
1935
- todoList.get('isDone'); // false
1936
- todoList.get('todos').clear();
1937
- todoList.get('isDone'); // true
1925
+ tom.get('fullName') // 'Tom Dale'
1938
1926
  ```
1939
1927
 
1940
- @since 1.6.0
1941
- @method empty
1942
- @for Ember.computed
1943
- @param {String} dependentKey
1944
- @return {Ember.ComputedProperty} computed property which negate
1945
- the original value for property
1946
- @public
1947
- */
1948
-
1949
- function empty(dependentKey) {
1950
- return _emberMetalComputed.computed(dependentKey + '.length', function () {
1951
- return _emberMetalIs_empty["default"](_emberMetalProperty_get.get(this, dependentKey));
1952
- });
1953
- }
1954
-
1955
- /**
1956
- A computed property that returns true if the value of the dependent
1957
- property is NOT null, an empty string, empty array, or empty function.
1958
-
1959
- Example
1928
+ You can also define what Ember should do when setting a computed property.
1929
+ If you try to set a computed property, it will be invoked with the key and
1930
+ value you want to set it to. You can also accept the previous value as the
1931
+ third parameter.
1960
1932
 
1961
1933
  ```javascript
1962
- var Hamster = Ember.Object.extend({
1963
- hasStuff: Ember.computed.notEmpty('backpack')
1934
+ var Person = Ember.Object.extend({
1935
+ // these will be supplied by `create`
1936
+ firstName: null,
1937
+ lastName: null,
1938
+
1939
+ fullName: function(key, value, oldValue) {
1940
+ // getter
1941
+ if (arguments.length === 1) {
1942
+ var firstName = this.get('firstName');
1943
+ var lastName = this.get('lastName');
1944
+
1945
+ return firstName + ' ' + lastName;
1946
+
1947
+ // setter
1948
+ } else {
1949
+ var name = value.split(' ');
1950
+
1951
+ this.set('firstName', name[0]);
1952
+ this.set('lastName', name[1]);
1953
+
1954
+ return value;
1955
+ }
1956
+ }.property('firstName', 'lastName')
1964
1957
  });
1965
1958
 
1966
- var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] });
1959
+ var person = Person.create();
1967
1960
 
1968
- hamster.get('hasStuff'); // true
1969
- hamster.get('backpack').clear(); // []
1970
- hamster.get('hasStuff'); // false
1961
+ person.set('fullName', 'Peter Wagenet');
1962
+ person.get('firstName'); // 'Peter'
1963
+ person.get('lastName'); // 'Wagenet'
1971
1964
  ```
1972
1965
 
1973
- @method notEmpty
1974
- @for Ember.computed
1975
- @param {String} dependentKey
1976
- @return {Ember.ComputedProperty} computed property which returns true if
1977
- original value for property is not empty.
1966
+ @class ComputedProperty
1967
+ @namespace Ember
1968
+ @constructor
1978
1969
  @public
1979
1970
  */
1971
+ function ComputedProperty(config, opts) {
1972
+ this.isDescriptor = true;
1973
+ if (typeof config === "function") {
1974
+ config.__ember_arity = config.length;
1975
+ this._getter = config;
1976
+ if (config.__ember_arity > 1) {
1977
+ _emberMetalCore["default"].deprecate("Using the same function as getter and setter is deprecated.", false, {
1978
+ url: "http://emberjs.com/deprecations/v1.x/#toc_deprecate-using-the-same-function-as-getter-and-setter-in-computed-properties"
1979
+ });
1980
+ this._setter = config;
1981
+ }
1982
+ } else {
1983
+ this._getter = config.get;
1984
+ this._setter = config.set;
1985
+ if (this._setter && this._setter.__ember_arity === undefined) {
1986
+ this._setter.__ember_arity = this._setter.length;
1987
+ }
1988
+ }
1980
1989
 
1981
- function notEmpty(dependentKey) {
1982
- return _emberMetalComputed.computed(dependentKey + '.length', function () {
1983
- return !_emberMetalIs_empty["default"](_emberMetalProperty_get.get(this, dependentKey));
1984
- });
1990
+ this._dependentKeys = undefined;
1991
+ this._suspended = undefined;
1992
+ this._meta = undefined;
1993
+
1994
+ _emberMetalCore["default"].deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable'));
1995
+ this._cacheable = opts && opts.cacheable !== undefined ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone.
1996
+ this._dependentKeys = opts && opts.dependentKeys;
1997
+ _emberMetalCore["default"].deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. You can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty('readOnly'));
1998
+ this._readOnly = opts && (opts.readOnly !== undefined || !!opts.readOnly) || false; // TODO: Set always to `false` once this deprecation is gone.
1985
1999
  }
1986
2000
 
2001
+ ComputedProperty.prototype = new _emberMetalProperties.Descriptor();
2002
+
2003
+ var ComputedPropertyPrototype = ComputedProperty.prototype;
2004
+
1987
2005
  /**
1988
- A computed property that returns true if the value of the dependent
1989
- property is null or undefined. This avoids errors from JSLint complaining
1990
- about use of ==, which can be technically confusing.
2006
+ Properties are cacheable by default. Computed property will automatically
2007
+ cache the return value of your function until one of the dependent keys changes.
1991
2008
 
1992
- Example
2009
+ Call `volatile()` to set it into non-cached mode. When in this mode
2010
+ the computed property will not automatically cache the return value.
1993
2011
 
1994
- ```javascript
1995
- var Hamster = Ember.Object.extend({
1996
- isHungry: Ember.computed.none('food')
1997
- });
2012
+ However, if a property is properly observable, there is no reason to disable
2013
+ caching.
1998
2014
 
1999
- var hamster = Hamster.create();
2015
+ @method cacheable
2016
+ @param {Boolean} aFlag optional set to `false` to disable caching
2017
+ @return {Ember.ComputedProperty} this
2018
+ @chainable
2019
+ @deprecated All computed properties are cacheble by default. Use `volatile()` instead to opt-out to caching.
2020
+ @public
2021
+ */
2022
+ ComputedPropertyPrototype.cacheable = function (aFlag) {
2023
+ _emberMetalCore["default"].deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.');
2024
+ this._cacheable = aFlag !== false;
2025
+ return this;
2026
+ };
2027
+
2028
+ /**
2029
+ Call on a computed property to set it into non-cached mode. When in this
2030
+ mode the computed property will not automatically cache the return value.
2000
2031
 
2001
- hamster.get('isHungry'); // true
2002
- hamster.set('food', 'Banana');
2003
- hamster.get('isHungry'); // false
2004
- hamster.set('food', null);
2005
- hamster.get('isHungry'); // true
2032
+ ```javascript
2033
+ var outsideService = Ember.Object.extend({
2034
+ value: function() {
2035
+ return OutsideService.getValue();
2036
+ }.property().volatile()
2037
+ }).create();
2006
2038
  ```
2007
2039
 
2008
- @method none
2009
- @for Ember.computed
2010
- @param {String} dependentKey
2011
- @return {Ember.ComputedProperty} computed property which
2012
- returns true if original value for property is null or undefined.
2040
+ @method volatile
2041
+ @return {Ember.ComputedProperty} this
2042
+ @chainable
2013
2043
  @public
2014
2044
  */
2015
-
2016
- function none(dependentKey) {
2017
- return _emberMetalComputed.computed(dependentKey, function () {
2018
- return _emberMetalIs_none["default"](_emberMetalProperty_get.get(this, dependentKey));
2019
- });
2020
- }
2045
+ ComputedPropertyPrototype["volatile"] = function () {
2046
+ this._cacheable = false;
2047
+ return this;
2048
+ };
2021
2049
 
2022
2050
  /**
2023
- A computed property that returns the inverse boolean value
2024
- of the original value for the dependent property.
2025
-
2026
- Example
2051
+ Call on a computed property to set it into read-only mode. When in this
2052
+ mode the computed property will throw an error when set.
2027
2053
 
2028
2054
  ```javascript
2029
- var User = Ember.Object.extend({
2030
- isAnonymous: Ember.computed.not('loggedIn')
2055
+ var Person = Ember.Object.extend({
2056
+ guid: function() {
2057
+ return 'guid-guid-guid';
2058
+ }.property().readOnly()
2031
2059
  });
2032
2060
 
2033
- var user = User.create({loggedIn: false});
2061
+ var person = Person.create();
2034
2062
 
2035
- user.get('isAnonymous'); // true
2036
- user.set('loggedIn', true);
2037
- user.get('isAnonymous'); // false
2063
+ person.set('guid', 'new-guid'); // will throw an exception
2038
2064
  ```
2039
2065
 
2040
- @method not
2041
- @for Ember.computed
2042
- @param {String} dependentKey
2043
- @return {Ember.ComputedProperty} computed property which returns
2044
- inverse of the original value for property
2066
+ @method readOnly
2067
+ @return {Ember.ComputedProperty} this
2068
+ @chainable
2045
2069
  @public
2046
2070
  */
2047
-
2048
- function not(dependentKey) {
2049
- return _emberMetalComputed.computed(dependentKey, function () {
2050
- return !_emberMetalProperty_get.get(this, dependentKey);
2051
- });
2052
- }
2071
+ ComputedPropertyPrototype.readOnly = function (readOnly) {
2072
+ _emberMetalCore["default"].deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0);
2073
+ this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone
2074
+ _emberMetalCore["default"].assert("Computed properties that define a setter using the new syntax cannot be read-only", !(this._readOnly && this._setter && this._setter !== this._getter));
2075
+ return this;
2076
+ };
2053
2077
 
2054
2078
  /**
2055
- A computed property that converts the provided dependent property
2056
- into a boolean value.
2079
+ Sets the dependent keys on this computed property. Pass any number of
2080
+ arguments containing key paths that this computed property depends on.
2057
2081
 
2058
2082
  ```javascript
2059
- var Hamster = Ember.Object.extend({
2060
- hasBananas: Ember.computed.bool('numBananas')
2083
+ var President = Ember.Object.extend({
2084
+ fullName: computed(function() {
2085
+ return this.get('firstName') + ' ' + this.get('lastName');
2086
+
2087
+ // Tell Ember that this computed property depends on firstName
2088
+ // and lastName
2089
+ }).property('firstName', 'lastName')
2061
2090
  });
2062
2091
 
2063
- var hamster = Hamster.create();
2092
+ var president = President.create({
2093
+ firstName: 'Barack',
2094
+ lastName: 'Obama'
2095
+ });
2064
2096
 
2065
- hamster.get('hasBananas'); // false
2066
- hamster.set('numBananas', 0);
2067
- hamster.get('hasBananas'); // false
2068
- hamster.set('numBananas', 1);
2069
- hamster.get('hasBananas'); // true
2070
- hamster.set('numBananas', null);
2071
- hamster.get('hasBananas'); // false
2097
+ president.get('fullName'); // 'Barack Obama'
2072
2098
  ```
2073
2099
 
2074
- @method bool
2075
- @for Ember.computed
2076
- @param {String} dependentKey
2077
- @return {Ember.ComputedProperty} computed property which converts
2078
- to boolean the original value for property
2100
+ @method property
2101
+ @param {String} path* zero or more property paths
2102
+ @return {Ember.ComputedProperty} this
2103
+ @chainable
2079
2104
  @public
2080
2105
  */
2106
+ ComputedPropertyPrototype.property = function () {
2107
+ var args;
2081
2108
 
2082
- function bool(dependentKey) {
2083
- return _emberMetalComputed.computed(dependentKey, function () {
2084
- return !!_emberMetalProperty_get.get(this, dependentKey);
2085
- });
2086
- }
2109
+ var addArg = function (property) {
2110
+ _emberMetalCore["default"].deprecate("Depending on arrays using a dependent key ending with `@each` is deprecated. " + ("Please refactor from `Ember.computed('" + property + "', function() {});` to `Ember.computed('" + property.slice(0, -6) + ".[]', function() {})`."), property.slice(-5) !== '@each', { id: 'ember-metal.@each-dependent-key-leaf', until: '2.0.0' });
2111
+
2112
+ args.push(property);
2113
+ };
2114
+
2115
+ args = [];
2116
+ for (var i = 0, l = arguments.length; i < l; i++) {
2117
+ _emberMetalExpand_properties["default"](arguments[i], addArg);
2118
+ }
2119
+
2120
+ this._dependentKeys = args;
2121
+ return this;
2122
+ };
2087
2123
 
2088
2124
  /**
2089
- A computed property which matches the original value for the
2090
- dependent property against a given RegExp, returning `true`
2091
- if they values matches the RegExp and `false` if it does not.
2092
-
2093
- Example
2094
-
2095
- ```javascript
2096
- var User = Ember.Object.extend({
2097
- hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/)
2098
- });
2125
+ In some cases, you may want to annotate computed properties with additional
2126
+ metadata about how they function or what values they operate on. For example,
2127
+ computed property functions may close over variables that are then no longer
2128
+ available for introspection.
2099
2129
 
2100
- var user = User.create({loggedIn: false});
2130
+ You can pass a hash of these values to a computed property like this:
2101
2131
 
2102
- user.get('hasValidEmail'); // false
2103
- user.set('email', '');
2104
- user.get('hasValidEmail'); // false
2105
- user.set('email', 'ember_hamster@example.com');
2106
- user.get('hasValidEmail'); // true
2132
+ ```
2133
+ person: function() {
2134
+ var personId = this.get('personId');
2135
+ return App.Person.create({ id: personId });
2136
+ }.property().meta({ type: App.Person })
2107
2137
  ```
2108
2138
 
2109
- @method match
2110
- @for Ember.computed
2111
- @param {String} dependentKey
2112
- @param {RegExp} regexp
2113
- @return {Ember.ComputedProperty} computed property which match
2114
- the original value for property against a given RegExp
2139
+ The hash that you pass to the `meta()` function will be saved on the
2140
+ computed property descriptor under the `_meta` key. Ember runtime
2141
+ exposes a public API for retrieving these values from classes,
2142
+ via the `metaForProperty()` function.
2143
+
2144
+ @method meta
2145
+ @param {Object} meta
2146
+ @chainable
2115
2147
  @public
2116
2148
  */
2117
2149
 
2118
- function match(dependentKey, regexp) {
2119
- return _emberMetalComputed.computed(dependentKey, function () {
2120
- var value = _emberMetalProperty_get.get(this, dependentKey);
2150
+ ComputedPropertyPrototype.meta = function (meta) {
2151
+ if (arguments.length === 0) {
2152
+ return this._meta || {};
2153
+ } else {
2154
+ this._meta = meta;
2155
+ return this;
2156
+ }
2157
+ };
2121
2158
 
2122
- return typeof value === 'string' ? regexp.test(value) : false;
2123
- });
2159
+ /* impl descriptor API */
2160
+ ComputedPropertyPrototype.didChange = function (obj, keyName) {
2161
+ // _suspended is set via a CP.set to ensure we don't clear
2162
+ // the cached value set by the setter
2163
+ if (this._cacheable && this._suspended !== obj) {
2164
+ var meta = metaFor(obj);
2165
+ if (meta.cache && meta.cache[keyName] !== undefined) {
2166
+ meta.cache[keyName] = undefined;
2167
+ _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
2168
+ }
2169
+ }
2170
+ };
2171
+
2172
+ function finishChains(chainNodes) {
2173
+ for (var i = 0, l = chainNodes.length; i < l; i++) {
2174
+ chainNodes[i].didChange(null);
2175
+ }
2124
2176
  }
2125
2177
 
2126
2178
  /**
2127
- A computed property that returns true if the provided dependent property
2128
- is equal to the given value.
2129
-
2130
- Example
2179
+ Access the value of the function backing the computed property.
2180
+ If this property has already been cached, return the cached result.
2181
+ Otherwise, call the function passing the property name as an argument.
2131
2182
 
2132
2183
  ```javascript
2133
- var Hamster = Ember.Object.extend({
2134
- napTime: Ember.computed.equal('state', 'sleepy')
2184
+ var Person = Ember.Object.extend({
2185
+ fullName: function(keyName) {
2186
+ // the keyName parameter is 'fullName' in this case.
2187
+ return this.get('firstName') + ' ' + this.get('lastName');
2188
+ }.property('firstName', 'lastName')
2135
2189
  });
2136
2190
 
2137
- var hamster = Hamster.create();
2138
2191
 
2139
- hamster.get('napTime'); // false
2140
- hamster.set('state', 'sleepy');
2141
- hamster.get('napTime'); // true
2142
- hamster.set('state', 'hungry');
2143
- hamster.get('napTime'); // false
2192
+ var tom = Person.create({
2193
+ firstName: 'Tom',
2194
+ lastName: 'Dale'
2195
+ });
2196
+
2197
+ tom.get('fullName') // 'Tom Dale'
2144
2198
  ```
2145
2199
 
2146
- @method equal
2147
- @for Ember.computed
2148
- @param {String} dependentKey
2149
- @param {String|Number|Object} value
2150
- @return {Ember.ComputedProperty} computed property which returns true if
2151
- the original value for property is equal to the given value.
2200
+ @method get
2201
+ @param {String} keyName The key being accessed.
2202
+ @return {Object} The return value of the function backing the CP.
2152
2203
  @public
2153
2204
  */
2205
+ ComputedPropertyPrototype.get = function (obj, keyName) {
2206
+ var ret, cache, meta, chainNodes;
2207
+ if (this._cacheable) {
2208
+ meta = metaFor(obj);
2209
+ cache = meta.cache;
2154
2210
 
2155
- function equal(dependentKey, value) {
2156
- return _emberMetalComputed.computed(dependentKey, function () {
2157
- return _emberMetalProperty_get.get(this, dependentKey) === value;
2158
- });
2159
- }
2211
+ var result = cache && cache[keyName];
2212
+
2213
+ if (result === UNDEFINED) {
2214
+ return undefined;
2215
+ } else if (result !== undefined) {
2216
+ return result;
2217
+ }
2218
+
2219
+ ret = this._getter.call(obj, keyName);
2220
+ cache = meta.cache;
2221
+ if (!cache) {
2222
+ cache = meta.cache = {};
2223
+ }
2224
+ if (ret === undefined) {
2225
+ cache[keyName] = UNDEFINED;
2226
+ } else {
2227
+ cache[keyName] = ret;
2228
+ }
2229
+
2230
+ chainNodes = meta.chainWatchers && meta.chainWatchers[keyName];
2231
+ if (chainNodes) {
2232
+ finishChains(chainNodes);
2233
+ }
2234
+ _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
2235
+ } else {
2236
+ ret = this._getter.call(obj, keyName);
2237
+ }
2238
+ return ret;
2239
+ };
2160
2240
 
2161
2241
  /**
2162
- A computed property that returns true if the provided dependent property
2163
- is greater than the provided value.
2242
+ Set the value of a computed property. If the function that backs your
2243
+ computed property does not accept arguments then the default action for
2244
+ setting would be to define the property on the current object, and set
2245
+ the value of the property to the value being set.
2164
2246
 
2165
- Example
2247
+ Generally speaking if you intend for your computed property to be set
2248
+ your backing function should accept either two or three arguments.
2166
2249
 
2167
2250
  ```javascript
2168
- var Hamster = Ember.Object.extend({
2169
- hasTooManyBananas: Ember.computed.gt('numBananas', 10)
2170
- });
2251
+ var Person = Ember.Object.extend({
2252
+ // these will be supplied by `create`
2253
+ firstName: null,
2254
+ lastName: null,
2171
2255
 
2172
- var hamster = Hamster.create();
2256
+ fullName: function(key, value, oldValue) {
2257
+ // getter
2258
+ if (arguments.length === 1) {
2259
+ var firstName = this.get('firstName');
2260
+ var lastName = this.get('lastName');
2173
2261
 
2174
- hamster.get('hasTooManyBananas'); // false
2175
- hamster.set('numBananas', 3);
2176
- hamster.get('hasTooManyBananas'); // false
2177
- hamster.set('numBananas', 11);
2178
- hamster.get('hasTooManyBananas'); // true
2179
- ```
2262
+ return firstName + ' ' + lastName;
2180
2263
 
2181
- @method gt
2182
- @for Ember.computed
2183
- @param {String} dependentKey
2184
- @param {Number} value
2185
- @return {Ember.ComputedProperty} computed property which returns true if
2186
- the original value for property is greater than given value.
2187
- @public
2188
- */
2189
-
2190
- function gt(dependentKey, value) {
2191
- return _emberMetalComputed.computed(dependentKey, function () {
2192
- return _emberMetalProperty_get.get(this, dependentKey) > value;
2193
- });
2194
- }
2195
-
2196
- /**
2197
- A computed property that returns true if the provided dependent property
2198
- is greater than or equal to the provided value.
2264
+ // setter
2265
+ } else {
2266
+ var name = value.split(' ');
2199
2267
 
2200
- Example
2268
+ this.set('firstName', name[0]);
2269
+ this.set('lastName', name[1]);
2201
2270
 
2202
- ```javascript
2203
- var Hamster = Ember.Object.extend({
2204
- hasTooManyBananas: Ember.computed.gte('numBananas', 10)
2271
+ return value;
2272
+ }
2273
+ }.property('firstName', 'lastName')
2205
2274
  });
2206
2275
 
2207
- var hamster = Hamster.create();
2276
+ var person = Person.create();
2208
2277
 
2209
- hamster.get('hasTooManyBananas'); // false
2210
- hamster.set('numBananas', 3);
2211
- hamster.get('hasTooManyBananas'); // false
2212
- hamster.set('numBananas', 10);
2213
- hamster.get('hasTooManyBananas'); // true
2278
+ person.set('fullName', 'Peter Wagenet');
2279
+ person.get('firstName'); // 'Peter'
2280
+ person.get('lastName'); // 'Wagenet'
2214
2281
  ```
2215
2282
 
2216
- @method gte
2217
- @for Ember.computed
2218
- @param {String} dependentKey
2219
- @param {Number} value
2220
- @return {Ember.ComputedProperty} computed property which returns true if
2221
- the original value for property is greater or equal then given value.
2283
+ @method set
2284
+ @param {String} keyName The key being accessed.
2285
+ @param {Object} newValue The new value being assigned.
2286
+ @param {String} oldValue The old value being replaced.
2287
+ @return {Object} The return value of the function backing the CP.
2222
2288
  @public
2223
2289
  */
2290
+ ComputedPropertyPrototype.set = function computedPropertySetWithSuspend(obj, keyName, value) {
2291
+ var oldSuspended = this._suspended;
2224
2292
 
2225
- function gte(dependentKey, value) {
2226
- return _emberMetalComputed.computed(dependentKey, function () {
2227
- return _emberMetalProperty_get.get(this, dependentKey) >= value;
2228
- });
2229
- }
2293
+ this._suspended = obj;
2294
+
2295
+ try {
2296
+ this._set(obj, keyName, value);
2297
+ } finally {
2298
+ this._suspended = oldSuspended;
2299
+ }
2300
+ };
2301
+
2302
+ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) {
2303
+ var cacheable = this._cacheable;
2304
+ var setter = this._setter;
2305
+ var meta = metaFor(obj, cacheable);
2306
+ var cache = meta.cache;
2307
+ var hadCachedValue = false;
2308
+
2309
+ var cachedValue, ret;
2310
+
2311
+ if (this._readOnly) {
2312
+ throw new _emberMetalError["default"]("Cannot set read-only property \"" + keyName + "\" on object: " + _emberMetalUtils.inspect(obj));
2313
+ }
2314
+
2315
+ if (cacheable && cache && cache[keyName] !== undefined) {
2316
+ if (cache[keyName] !== UNDEFINED) {
2317
+ cachedValue = cache[keyName];
2318
+ }
2319
+
2320
+ hadCachedValue = true;
2321
+ }
2322
+
2323
+ if (!setter) {
2324
+ _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue);
2325
+ _emberMetalProperty_set.set(obj, keyName, value);
2326
+ return;
2327
+ } else if (setter.__ember_arity === 2) {
2328
+ // Is there any way of deprecate this in a sensitive way?
2329
+ // Maybe now that getters and setters are the prefered options we can....
2330
+ ret = setter.call(obj, keyName, value);
2331
+ } else {
2332
+ ret = setter.call(obj, keyName, value, cachedValue);
2333
+ }
2334
+
2335
+ if (hadCachedValue && cachedValue === ret) {
2336
+ return;
2337
+ }
2338
+
2339
+ var watched = meta.watching[keyName];
2340
+ if (watched) {
2341
+ _emberMetalProperty_events.propertyWillChange(obj, keyName);
2342
+ }
2343
+
2344
+ if (hadCachedValue) {
2345
+ cache[keyName] = undefined;
2346
+ }
2347
+
2348
+ if (cacheable) {
2349
+ if (!hadCachedValue) {
2350
+ _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
2351
+ }
2352
+ if (!cache) {
2353
+ cache = meta.cache = {};
2354
+ }
2355
+ if (ret === undefined) {
2356
+ cache[keyName] = UNDEFINED;
2357
+ } else {
2358
+ cache[keyName] = ret;
2359
+ }
2360
+ }
2361
+
2362
+ if (watched) {
2363
+ _emberMetalProperty_events.propertyDidChange(obj, keyName);
2364
+ }
2365
+
2366
+ return ret;
2367
+ };
2368
+
2369
+ /* called before property is overridden */
2370
+ ComputedPropertyPrototype.teardown = function (obj, keyName) {
2371
+ var meta = metaFor(obj);
2372
+
2373
+ if (meta.cache) {
2374
+ if (keyName in meta.cache) {
2375
+ _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
2376
+ }
2377
+
2378
+ if (this._cacheable) {
2379
+ delete meta.cache[keyName];
2380
+ }
2381
+ }
2382
+
2383
+ return null; // no value to restore
2384
+ };
2230
2385
 
2231
2386
  /**
2232
- A computed property that returns true if the provided dependent property
2233
- is less than the provided value.
2234
-
2235
- Example
2387
+ This helper returns a new property descriptor that wraps the passed
2388
+ computed property function. You can use this helper to define properties
2389
+ with mixins or via `Ember.defineProperty()`.
2236
2390
 
2237
- ```javascript
2238
- var Hamster = Ember.Object.extend({
2239
- needsMoreBananas: Ember.computed.lt('numBananas', 3)
2240
- });
2391
+ The function you pass will be used to both get and set property values.
2392
+ The function should accept two parameters, key and value. If value is not
2393
+ undefined you should set the value first. In either case return the
2394
+ current value of the property.
2241
2395
 
2242
- var hamster = Hamster.create();
2396
+ A computed property defined in this way might look like this:
2243
2397
 
2244
- hamster.get('needsMoreBananas'); // true
2245
- hamster.set('numBananas', 3);
2246
- hamster.get('needsMoreBananas'); // false
2247
- hamster.set('numBananas', 2);
2248
- hamster.get('needsMoreBananas'); // true
2249
- ```
2398
+ ```js
2399
+ var Person = Ember.Object.extend({
2400
+ firstName: 'Betty',
2401
+ lastName: 'Jones',
2250
2402
 
2251
- @method lt
2252
- @for Ember.computed
2253
- @param {String} dependentKey
2254
- @param {Number} value
2255
- @return {Ember.ComputedProperty} computed property which returns true if
2256
- the original value for property is less then given value.
2257
- @public
2258
- */
2259
-
2260
- function lt(dependentKey, value) {
2261
- return _emberMetalComputed.computed(dependentKey, function () {
2262
- return _emberMetalProperty_get.get(this, dependentKey) < value;
2403
+ fullName: Ember.computed('firstName', 'lastName', function(key, value) {
2404
+ return this.get('firstName') + ' ' + this.get('lastName');
2405
+ })
2263
2406
  });
2264
- }
2265
-
2266
- /**
2267
- A computed property that returns true if the provided dependent property
2268
- is less than or equal to the provided value.
2269
2407
 
2270
- Example
2408
+ var client = Person.create();
2271
2409
 
2272
- ```javascript
2273
- var Hamster = Ember.Object.extend({
2274
- needsMoreBananas: Ember.computed.lte('numBananas', 3)
2275
- });
2410
+ client.get('fullName'); // 'Betty Jones'
2276
2411
 
2277
- var hamster = Hamster.create();
2412
+ client.set('lastName', 'Fuller');
2413
+ client.get('fullName'); // 'Betty Fuller'
2414
+ ```
2278
2415
 
2279
- hamster.get('needsMoreBananas'); // true
2280
- hamster.set('numBananas', 5);
2281
- hamster.get('needsMoreBananas'); // false
2282
- hamster.set('numBananas', 3);
2283
- hamster.get('needsMoreBananas'); // true
2416
+ _Note: This is the preferred way to define computed properties when writing third-party
2417
+ libraries that depend on or use Ember, since there is no guarantee that the user
2418
+ will have prototype extensions enabled._
2419
+
2420
+ You might use this method if you disabled
2421
+ [Prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/).
2422
+ The alternative syntax might look like this
2423
+ (if prototype extensions are enabled, which is the default behavior):
2424
+
2425
+ ```js
2426
+ fullName: function () {
2427
+ return this.get('firstName') + ' ' + this.get('lastName');
2428
+ }.property('firstName', 'lastName')
2284
2429
  ```
2285
2430
 
2286
- @method lte
2287
- @for Ember.computed
2288
- @param {String} dependentKey
2289
- @param {Number} value
2290
- @return {Ember.ComputedProperty} computed property which returns true if
2291
- the original value for property is less or equal than given value.
2431
+ @class computed
2432
+ @namespace Ember
2433
+ @constructor
2434
+ @static
2435
+ @param {String} [dependentKeys*] Optional dependent keys that trigger this computed property.
2436
+ @param {Function} func The computed property function.
2437
+ @return {Ember.ComputedProperty} property descriptor instance
2292
2438
  @public
2293
2439
  */
2440
+ function computed(func) {
2441
+ var args;
2294
2442
 
2295
- function lte(dependentKey, value) {
2296
- return _emberMetalComputed.computed(dependentKey, function () {
2297
- return _emberMetalProperty_get.get(this, dependentKey) <= value;
2298
- });
2443
+ if (arguments.length > 1) {
2444
+ args = [].slice.call(arguments);
2445
+ func = args.pop();
2446
+ }
2447
+
2448
+ var cp = new ComputedProperty(func);
2449
+
2450
+ if (args) {
2451
+ cp.property.apply(cp, args);
2452
+ }
2453
+
2454
+ return cp;
2299
2455
  }
2300
2456
 
2301
2457
  /**
2302
- A computed property that performs a logical `and` on the
2303
- original values for the provided dependent properties.
2304
-
2305
- Example
2306
-
2307
- ```javascript
2308
- var Hamster = Ember.Object.extend({
2309
- readyForCamp: Ember.computed.and('hasTent', 'hasBackpack')
2310
- });
2311
-
2312
- var hamster = Hamster.create();
2313
-
2314
- hamster.get('readyForCamp'); // false
2315
- hamster.set('hasTent', true);
2316
- hamster.get('readyForCamp'); // false
2317
- hamster.set('hasBackpack', true);
2318
- hamster.get('readyForCamp'); // true
2319
- hamster.set('hasBackpack', 'Yes');
2320
- hamster.get('readyForCamp'); // 'Yes'
2321
- ```
2458
+ Returns the cached value for a property, if one exists.
2459
+ This can be useful for peeking at the value of a computed
2460
+ property that is generated lazily, without accidentally causing
2461
+ it to be created.
2322
2462
 
2323
- @method and
2324
- @for Ember.computed
2325
- @param {String} dependentKey*
2326
- @return {Ember.ComputedProperty} computed property which performs
2327
- a logical `and` on the values of all the original values for properties.
2463
+ @method cacheFor
2464
+ @for Ember
2465
+ @param {Object} obj the object whose property you want to check
2466
+ @param {String} key the name of the property whose cached value you want
2467
+ to return
2468
+ @return {Object} the cached value
2328
2469
  @public
2329
2470
  */
2330
- var and = generateComputedWithProperties(function (properties) {
2331
- var value;
2332
- for (var key in properties) {
2333
- value = properties[key];
2334
- if (properties.hasOwnProperty(key) && !value) {
2335
- return false;
2336
- }
2471
+ function cacheFor(obj, key) {
2472
+ var meta = obj['__ember_meta__'];
2473
+ var cache = meta && meta.cache;
2474
+ var ret = cache && cache[key];
2475
+
2476
+ if (ret === UNDEFINED) {
2477
+ return undefined;
2337
2478
  }
2338
- return value;
2339
- });
2479
+ return ret;
2480
+ }
2481
+
2482
+ cacheFor.set = function (cache, key, value) {
2483
+ if (value === undefined) {
2484
+ cache[key] = UNDEFINED;
2485
+ } else {
2486
+ cache[key] = value;
2487
+ }
2488
+ };
2489
+
2490
+ cacheFor.get = function (cache, key) {
2491
+ var ret = cache[key];
2492
+ if (ret === UNDEFINED) {
2493
+ return undefined;
2494
+ }
2495
+ return ret;
2496
+ };
2497
+
2498
+ cacheFor.remove = function (cache, key) {
2499
+ cache[key] = undefined;
2500
+ };
2501
+
2502
+ exports.ComputedProperty = ComputedProperty;
2503
+ exports.computed = computed;
2504
+ exports.cacheFor = cacheFor;
2505
+ });
2506
+ enifed("ember-metal/computed_macros", ["exports", "ember-metal/core", "ember-metal/property_get", "ember-metal/property_set", "ember-metal/computed", "ember-metal/is_empty", "ember-metal/is_none", "ember-metal/alias"], function (exports, _emberMetalCore, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalComputed, _emberMetalIs_empty, _emberMetalIs_none, _emberMetalAlias) {
2507
+ "use strict";
2508
+
2509
+ exports.empty = empty;
2510
+ exports.notEmpty = notEmpty;
2511
+ exports.none = none;
2512
+ exports.not = not;
2513
+ exports.bool = bool;
2514
+ exports.match = match;
2515
+ exports.equal = equal;
2516
+ exports.gt = gt;
2517
+ exports.gte = gte;
2518
+ exports.lt = lt;
2519
+ exports.lte = lte;
2520
+ exports.oneWay = oneWay;
2521
+ exports.readOnly = readOnly;
2522
+ exports.defaultTo = defaultTo;
2523
+ exports.deprecatingAlias = deprecatingAlias;
2340
2524
 
2341
- exports.and = and;
2342
2525
  /**
2343
- A computed property which performs a logical `or` on the
2344
- original values for the provided dependent properties.
2345
-
2346
- Example
2347
-
2348
- ```javascript
2349
- var Hamster = Ember.Object.extend({
2350
- readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella')
2351
- });
2352
-
2353
- var hamster = Hamster.create();
2354
-
2355
- hamster.get('readyForRain'); // false
2356
- hamster.set('hasUmbrella', true);
2357
- hamster.get('readyForRain'); // true
2358
- hamster.set('hasJacket', 'Yes');
2359
- hamster.get('readyForRain'); // 'Yes'
2360
- ```
2361
-
2362
- @method or
2363
- @for Ember.computed
2364
- @param {String} dependentKey*
2365
- @return {Ember.ComputedProperty} computed property which performs
2366
- a logical `or` on the values of all the original values for properties.
2367
- @public
2526
+ @module ember
2527
+ @submodule ember-metal
2368
2528
  */
2369
- var or = generateComputedWithProperties(function (properties) {
2370
- for (var key in properties) {
2371
- if (properties.hasOwnProperty(key) && properties[key]) {
2372
- return properties[key];
2373
- }
2529
+
2530
+ function getProperties(self, propertyNames) {
2531
+ var ret = {};
2532
+ for (var i = 0; i < propertyNames.length; i++) {
2533
+ ret[propertyNames[i]] = _emberMetalProperty_get.get(self, propertyNames[i]);
2374
2534
  }
2375
- return false;
2376
- });
2535
+ return ret;
2536
+ }
2537
+
2538
+ function generateComputedWithProperties(macro) {
2539
+ return function () {
2540
+ for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
2541
+ properties[_key] = arguments[_key];
2542
+ }
2543
+
2544
+ var computedFunc = _emberMetalComputed.computed(function () {
2545
+ return macro.apply(this, [getProperties(this, properties)]);
2546
+ });
2547
+
2548
+ return computedFunc.property.apply(computedFunc, properties);
2549
+ };
2550
+ }
2377
2551
 
2378
- exports.or = or;
2379
2552
  /**
2380
- A computed property that returns the first truthy value
2381
- from a list of dependent properties.
2553
+ A computed property that returns true if the value of the dependent
2554
+ property is null, an empty string, empty array, or empty function.
2382
2555
 
2383
2556
  Example
2384
2557
 
2385
2558
  ```javascript
2386
- var Hamster = Ember.Object.extend({
2387
- hasClothes: Ember.computed.any('hat', 'shirt')
2559
+ var ToDoList = Ember.Object.extend({
2560
+ isDone: Ember.computed.empty('todos')
2388
2561
  });
2389
2562
 
2390
- var hamster = Hamster.create();
2563
+ var todoList = ToDoList.create({
2564
+ todos: ['Unit Test', 'Documentation', 'Release']
2565
+ });
2391
2566
 
2392
- hamster.get('hasClothes'); // null
2393
- hamster.set('shirt', 'Hawaiian Shirt');
2394
- hamster.get('hasClothes'); // 'Hawaiian Shirt'
2567
+ todoList.get('isDone'); // false
2568
+ todoList.get('todos').clear();
2569
+ todoList.get('isDone'); // true
2395
2570
  ```
2396
2571
 
2397
- @method any
2572
+ @since 1.6.0
2573
+ @method empty
2398
2574
  @for Ember.computed
2399
- @param {String} dependentKey*
2400
- @return {Ember.ComputedProperty} computed property which returns
2401
- the first truthy value of given list of properties.
2402
- @deprecated Use `Ember.computed.or` instead.
2575
+ @param {String} dependentKey
2576
+ @return {Ember.ComputedProperty} computed property which negate
2577
+ the original value for property
2403
2578
  @public
2404
2579
  */
2405
- var any = generateComputedWithProperties(function (properties) {
2406
- _emberMetalCore["default"].deprecate('Usage of Ember.computed.any is deprecated, use `Ember.computed.or` instead.');
2407
- for (var key in properties) {
2408
- if (properties.hasOwnProperty(key) && properties[key]) {
2409
- return properties[key];
2410
- }
2411
- }
2412
- return null;
2413
- });
2414
2580
 
2415
- exports.any = any;
2581
+ function empty(dependentKey) {
2582
+ return _emberMetalComputed.computed(dependentKey + '.length', function () {
2583
+ return _emberMetalIs_empty["default"](_emberMetalProperty_get.get(this, dependentKey));
2584
+ });
2585
+ }
2586
+
2416
2587
  /**
2417
- A computed property that returns the array of values
2418
- for the provided dependent properties.
2588
+ A computed property that returns true if the value of the dependent
2589
+ property is NOT null, an empty string, empty array, or empty function.
2419
2590
 
2420
2591
  Example
2421
2592
 
2422
2593
  ```javascript
2423
2594
  var Hamster = Ember.Object.extend({
2424
- clothes: Ember.computed.collect('hat', 'shirt')
2595
+ hasStuff: Ember.computed.notEmpty('backpack')
2425
2596
  });
2426
2597
 
2427
- var hamster = Hamster.create();
2598
+ var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] });
2428
2599
 
2429
- hamster.get('clothes'); // [null, null]
2430
- hamster.set('hat', 'Camp Hat');
2431
- hamster.set('shirt', 'Camp Shirt');
2432
- hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
2600
+ hamster.get('hasStuff'); // true
2601
+ hamster.get('backpack').clear(); // []
2602
+ hamster.get('hasStuff'); // false
2433
2603
  ```
2434
2604
 
2435
- @method collect
2605
+ @method notEmpty
2436
2606
  @for Ember.computed
2437
- @param {String} dependentKey*
2438
- @return {Ember.ComputedProperty} computed property which maps
2439
- values of all passed in properties to an array.
2607
+ @param {String} dependentKey
2608
+ @return {Ember.ComputedProperty} computed property which returns true if
2609
+ original value for property is not empty.
2440
2610
  @public
2441
2611
  */
2442
- var collect = generateComputedWithProperties(function (properties) {
2443
- var res = _emberMetalCore["default"].A();
2444
- for (var key in properties) {
2445
- if (properties.hasOwnProperty(key)) {
2446
- if (_emberMetalIs_none["default"](properties[key])) {
2447
- res.push(null);
2448
- } else {
2449
- res.push(properties[key]);
2450
- }
2451
- }
2452
- }
2453
- return res;
2454
- });
2455
2612
 
2456
- exports.collect = collect;
2613
+ function notEmpty(dependentKey) {
2614
+ return _emberMetalComputed.computed(dependentKey + '.length', function () {
2615
+ return !_emberMetalIs_empty["default"](_emberMetalProperty_get.get(this, dependentKey));
2616
+ });
2617
+ }
2618
+
2457
2619
  /**
2458
- Creates a new property that is an alias for another property
2459
- on an object. Calls to `get` or `set` this property behave as
2460
- though they were called on the original property.
2620
+ A computed property that returns true if the value of the dependent
2621
+ property is null or undefined. This avoids errors from JSLint complaining
2622
+ about use of ==, which can be technically confusing.
2623
+
2624
+ Example
2461
2625
 
2462
2626
  ```javascript
2463
- var Person = Ember.Object.extend({
2464
- name: 'Alex Matchneer',
2465
- nomen: Ember.computed.alias('name')
2627
+ var Hamster = Ember.Object.extend({
2628
+ isHungry: Ember.computed.none('food')
2466
2629
  });
2467
2630
 
2468
- var alex = Person.create();
2469
-
2470
- alex.get('nomen'); // 'Alex Matchneer'
2471
- alex.get('name'); // 'Alex Matchneer'
2631
+ var hamster = Hamster.create();
2472
2632
 
2473
- alex.set('nomen', '@machty');
2474
- alex.get('name'); // '@machty'
2633
+ hamster.get('isHungry'); // true
2634
+ hamster.set('food', 'Banana');
2635
+ hamster.get('isHungry'); // false
2636
+ hamster.set('food', null);
2637
+ hamster.get('isHungry'); // true
2475
2638
  ```
2476
2639
 
2477
- @method alias
2640
+ @method none
2478
2641
  @for Ember.computed
2479
2642
  @param {String} dependentKey
2480
- @return {Ember.ComputedProperty} computed property which creates an
2481
- alias to the original value for property.
2643
+ @return {Ember.ComputedProperty} computed property which
2644
+ returns true if original value for property is null or undefined.
2482
2645
  @public
2483
2646
  */
2484
2647
 
2648
+ function none(dependentKey) {
2649
+ return _emberMetalComputed.computed(dependentKey, function () {
2650
+ return _emberMetalIs_none["default"](_emberMetalProperty_get.get(this, dependentKey));
2651
+ });
2652
+ }
2653
+
2485
2654
  /**
2486
- Where `computed.alias` aliases `get` and `set`, and allows for bidirectional
2487
- data flow, `computed.oneWay` only provides an aliased `get`. The `set` will
2488
- not mutate the upstream property, rather causes the current property to
2489
- become the value set. This causes the downstream property to permanently
2490
- diverge from the upstream property.
2655
+ A computed property that returns the inverse boolean value
2656
+ of the original value for the dependent property.
2491
2657
 
2492
2658
  Example
2493
2659
 
2494
2660
  ```javascript
2495
2661
  var User = Ember.Object.extend({
2496
- firstName: null,
2497
- lastName: null,
2498
- nickName: Ember.computed.oneWay('firstName')
2662
+ isAnonymous: Ember.computed.not('loggedIn')
2499
2663
  });
2500
2664
 
2501
- var teddy = User.create({
2502
- firstName: 'Teddy',
2503
- lastName: 'Zeenny'
2504
- });
2665
+ var user = User.create({loggedIn: false});
2505
2666
 
2506
- teddy.get('nickName'); // 'Teddy'
2507
- teddy.set('nickName', 'TeddyBear'); // 'TeddyBear'
2508
- teddy.get('firstName'); // 'Teddy'
2667
+ user.get('isAnonymous'); // true
2668
+ user.set('loggedIn', true);
2669
+ user.get('isAnonymous'); // false
2509
2670
  ```
2510
2671
 
2511
- @method oneWay
2672
+ @method not
2512
2673
  @for Ember.computed
2513
2674
  @param {String} dependentKey
2514
- @return {Ember.ComputedProperty} computed property which creates a
2515
- one way computed property to the original value for property.
2675
+ @return {Ember.ComputedProperty} computed property which returns
2676
+ inverse of the original value for property
2516
2677
  @public
2517
2678
  */
2518
2679
 
2519
- function oneWay(dependentKey) {
2520
- return _emberMetalAlias["default"](dependentKey).oneWay();
2680
+ function not(dependentKey) {
2681
+ return _emberMetalComputed.computed(dependentKey, function () {
2682
+ return !_emberMetalProperty_get.get(this, dependentKey);
2683
+ });
2521
2684
  }
2522
2685
 
2523
2686
  /**
2524
- This is a more semantically meaningful alias of `computed.oneWay`,
2525
- whose name is somewhat ambiguous as to which direction the data flows.
2526
-
2527
- @method reads
2528
- @for Ember.computed
2529
- @param {String} dependentKey
2530
- @return {Ember.ComputedProperty} computed property which creates a
2531
- one way computed property to the original value for property.
2532
- @public
2533
- */
2534
-
2535
- /**
2536
- Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides
2537
- a readOnly one way binding. Very often when using `computed.oneWay` one does
2538
- not also want changes to propagate back up, as they will replace the value.
2539
-
2540
- This prevents the reverse flow, and also throws an exception when it occurs.
2541
-
2542
- Example
2687
+ A computed property that converts the provided dependent property
2688
+ into a boolean value.
2543
2689
 
2544
2690
  ```javascript
2545
- var User = Ember.Object.extend({
2546
- firstName: null,
2547
- lastName: null,
2548
- nickName: Ember.computed.readOnly('firstName')
2691
+ var Hamster = Ember.Object.extend({
2692
+ hasBananas: Ember.computed.bool('numBananas')
2549
2693
  });
2550
2694
 
2551
- var teddy = User.create({
2552
- firstName: 'Teddy',
2553
- lastName: 'Zeenny'
2554
- });
2695
+ var hamster = Hamster.create();
2555
2696
 
2556
- teddy.get('nickName'); // 'Teddy'
2557
- teddy.set('nickName', 'TeddyBear'); // throws Exception
2558
- // throw new Ember.Error('Cannot Set: nickName on: <User:ember27288>' );`
2559
- teddy.get('firstName'); // 'Teddy'
2697
+ hamster.get('hasBananas'); // false
2698
+ hamster.set('numBananas', 0);
2699
+ hamster.get('hasBananas'); // false
2700
+ hamster.set('numBananas', 1);
2701
+ hamster.get('hasBananas'); // true
2702
+ hamster.set('numBananas', null);
2703
+ hamster.get('hasBananas'); // false
2560
2704
  ```
2561
2705
 
2562
- @method readOnly
2706
+ @method bool
2563
2707
  @for Ember.computed
2564
2708
  @param {String} dependentKey
2565
- @return {Ember.ComputedProperty} computed property which creates a
2566
- one way computed property to the original value for property.
2567
- @since 1.5.0
2709
+ @return {Ember.ComputedProperty} computed property which converts
2710
+ to boolean the original value for property
2568
2711
  @public
2569
2712
  */
2570
2713
 
2571
- function readOnly(dependentKey) {
2572
- return _emberMetalAlias["default"](dependentKey).readOnly();
2714
+ function bool(dependentKey) {
2715
+ return _emberMetalComputed.computed(dependentKey, function () {
2716
+ return !!_emberMetalProperty_get.get(this, dependentKey);
2717
+ });
2573
2718
  }
2574
2719
 
2575
2720
  /**
2576
- A computed property that acts like a standard getter and setter,
2577
- but returns the value at the provided `defaultPath` if the
2578
- property itself has not been set to a value
2721
+ A computed property which matches the original value for the
2722
+ dependent property against a given RegExp, returning `true`
2723
+ if they values matches the RegExp and `false` if it does not.
2579
2724
 
2580
2725
  Example
2581
2726
 
2582
2727
  ```javascript
2583
- var Hamster = Ember.Object.extend({
2584
- wishList: Ember.computed.defaultTo('favoriteFood')
2728
+ var User = Ember.Object.extend({
2729
+ hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/)
2585
2730
  });
2586
2731
 
2587
- var hamster = Hamster.create({ favoriteFood: 'Banana' });
2732
+ var user = User.create({loggedIn: false});
2588
2733
 
2589
- hamster.get('wishList'); // 'Banana'
2590
- hamster.set('wishList', 'More Unit Tests');
2591
- hamster.get('wishList'); // 'More Unit Tests'
2592
- hamster.get('favoriteFood'); // 'Banana'
2734
+ user.get('hasValidEmail'); // false
2735
+ user.set('email', '');
2736
+ user.get('hasValidEmail'); // false
2737
+ user.set('email', 'ember_hamster@example.com');
2738
+ user.get('hasValidEmail'); // true
2593
2739
  ```
2594
2740
 
2595
- @method defaultTo
2741
+ @method match
2596
2742
  @for Ember.computed
2597
- @param {String} defaultPath
2598
- @return {Ember.ComputedProperty} computed property which acts like
2599
- a standard getter and setter, but defaults to the value from `defaultPath`.
2600
- @deprecated Use `Ember.computed.oneWay` or custom CP with default instead.
2743
+ @param {String} dependentKey
2744
+ @param {RegExp} regexp
2745
+ @return {Ember.ComputedProperty} computed property which match
2746
+ the original value for property against a given RegExp
2601
2747
  @public
2602
2748
  */
2603
2749
 
2604
- function defaultTo(defaultPath) {
2605
- return _emberMetalComputed.computed({
2606
- get: function (key) {
2607
- _emberMetalCore["default"].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
2608
- return _emberMetalProperty_get.get(this, defaultPath);
2609
- },
2750
+ function match(dependentKey, regexp) {
2751
+ return _emberMetalComputed.computed(dependentKey, function () {
2752
+ var value = _emberMetalProperty_get.get(this, dependentKey);
2610
2753
 
2611
- set: function (key, newValue, cachedValue) {
2612
- _emberMetalCore["default"].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
2613
- return newValue != null ? newValue : _emberMetalProperty_get.get(this, defaultPath);
2614
- }
2754
+ return typeof value === 'string' ? regexp.test(value) : false;
2615
2755
  });
2616
2756
  }
2617
2757
 
2618
2758
  /**
2619
- Creates a new property that is an alias for another property
2620
- on an object. Calls to `get` or `set` this property behave as
2621
- though they were called on the original property, but also
2622
- print a deprecation warning.
2759
+ A computed property that returns true if the provided dependent property
2760
+ is equal to the given value.
2623
2761
 
2624
- @method deprecatingAlias
2762
+ Example
2763
+
2764
+ ```javascript
2765
+ var Hamster = Ember.Object.extend({
2766
+ napTime: Ember.computed.equal('state', 'sleepy')
2767
+ });
2768
+
2769
+ var hamster = Hamster.create();
2770
+
2771
+ hamster.get('napTime'); // false
2772
+ hamster.set('state', 'sleepy');
2773
+ hamster.get('napTime'); // true
2774
+ hamster.set('state', 'hungry');
2775
+ hamster.get('napTime'); // false
2776
+ ```
2777
+
2778
+ @method equal
2625
2779
  @for Ember.computed
2626
2780
  @param {String} dependentKey
2627
- @return {Ember.ComputedProperty} computed property which creates an
2628
- alias with a deprecation to the original value for property.
2629
- @since 1.7.0
2781
+ @param {String|Number|Object} value
2782
+ @return {Ember.ComputedProperty} computed property which returns true if
2783
+ the original value for property is equal to the given value.
2630
2784
  @public
2631
2785
  */
2632
2786
 
2633
- function deprecatingAlias(dependentKey) {
2634
- return _emberMetalComputed.computed(dependentKey, {
2635
- get: function (key) {
2636
- _emberMetalCore["default"].deprecate("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.");
2637
- return _emberMetalProperty_get.get(this, dependentKey);
2638
- },
2639
- set: function (key, value) {
2640
- _emberMetalCore["default"].deprecate("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.");
2641
- _emberMetalProperty_set.set(this, dependentKey, value);
2642
- return value;
2643
- }
2787
+ function equal(dependentKey, value) {
2788
+ return _emberMetalComputed.computed(dependentKey, function () {
2789
+ return _emberMetalProperty_get.get(this, dependentKey) === value;
2644
2790
  });
2645
2791
  }
2646
- });
2647
- enifed("ember-metal/computed", ["exports", "ember-metal/core", "ember-metal/property_set", "ember-metal/utils", "ember-metal/expand_properties", "ember-metal/error", "ember-metal/properties", "ember-metal/property_events", "ember-metal/dependent_keys"], function (exports, _emberMetalCore, _emberMetalProperty_set, _emberMetalUtils, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) {
2648
- "use strict";
2649
-
2650
- /**
2651
- @module ember
2652
- @submodule ember-metal
2653
- */
2654
-
2655
- var metaFor = _emberMetalUtils.meta;
2656
-
2657
- function UNDEFINED() {}
2658
-
2659
- // ..........................................................
2660
- // COMPUTED PROPERTY
2661
- //
2662
2792
 
2663
2793
  /**
2664
- A computed property transforms an object's function into a property.
2665
-
2666
- By default the function backing the computed property will only be called
2667
- once and the result will be cached. You can specify various properties
2668
- that your computed property depends on. This will force the cached
2669
- result to be recomputed if the dependencies are modified.
2670
-
2671
- In the following example we declare a computed property (by calling
2672
- `.property()` on the fullName function) and setup the property
2673
- dependencies (depending on firstName and lastName). The fullName function
2674
- will be called once (regardless of how many times it is accessed) as long
2675
- as its dependencies have not changed. Once firstName or lastName are updated
2676
- any future calls (or anything bound) to fullName will incorporate the new
2677
- values.
2678
-
2679
- ```javascript
2680
- var Person = Ember.Object.extend({
2681
- // these will be supplied by `create`
2682
- firstName: null,
2683
- lastName: null,
2684
-
2685
- fullName: function() {
2686
- var firstName = this.get('firstName');
2687
- var lastName = this.get('lastName');
2794
+ A computed property that returns true if the provided dependent property
2795
+ is greater than the provided value.
2688
2796
 
2689
- return firstName + ' ' + lastName;
2690
- }.property('firstName', 'lastName')
2691
- });
2797
+ Example
2692
2798
 
2693
- var tom = Person.create({
2694
- firstName: 'Tom',
2695
- lastName: 'Dale'
2799
+ ```javascript
2800
+ var Hamster = Ember.Object.extend({
2801
+ hasTooManyBananas: Ember.computed.gt('numBananas', 10)
2696
2802
  });
2697
2803
 
2698
- tom.get('fullName') // 'Tom Dale'
2804
+ var hamster = Hamster.create();
2805
+
2806
+ hamster.get('hasTooManyBananas'); // false
2807
+ hamster.set('numBananas', 3);
2808
+ hamster.get('hasTooManyBananas'); // false
2809
+ hamster.set('numBananas', 11);
2810
+ hamster.get('hasTooManyBananas'); // true
2699
2811
  ```
2700
2812
 
2701
- You can also define what Ember should do when setting a computed property.
2702
- If you try to set a computed property, it will be invoked with the key and
2703
- value you want to set it to. You can also accept the previous value as the
2704
- third parameter.
2813
+ @method gt
2814
+ @for Ember.computed
2815
+ @param {String} dependentKey
2816
+ @param {Number} value
2817
+ @return {Ember.ComputedProperty} computed property which returns true if
2818
+ the original value for property is greater than given value.
2819
+ @public
2820
+ */
2821
+
2822
+ function gt(dependentKey, value) {
2823
+ return _emberMetalComputed.computed(dependentKey, function () {
2824
+ return _emberMetalProperty_get.get(this, dependentKey) > value;
2825
+ });
2826
+ }
2827
+
2828
+ /**
2829
+ A computed property that returns true if the provided dependent property
2830
+ is greater than or equal to the provided value.
2831
+
2832
+ Example
2705
2833
 
2706
2834
  ```javascript
2707
- var Person = Ember.Object.extend({
2708
- // these will be supplied by `create`
2709
- firstName: null,
2710
- lastName: null,
2835
+ var Hamster = Ember.Object.extend({
2836
+ hasTooManyBananas: Ember.computed.gte('numBananas', 10)
2837
+ });
2711
2838
 
2712
- fullName: function(key, value, oldValue) {
2713
- // getter
2714
- if (arguments.length === 1) {
2715
- var firstName = this.get('firstName');
2716
- var lastName = this.get('lastName');
2839
+ var hamster = Hamster.create();
2717
2840
 
2718
- return firstName + ' ' + lastName;
2841
+ hamster.get('hasTooManyBananas'); // false
2842
+ hamster.set('numBananas', 3);
2843
+ hamster.get('hasTooManyBananas'); // false
2844
+ hamster.set('numBananas', 10);
2845
+ hamster.get('hasTooManyBananas'); // true
2846
+ ```
2719
2847
 
2720
- // setter
2721
- } else {
2722
- var name = value.split(' ');
2848
+ @method gte
2849
+ @for Ember.computed
2850
+ @param {String} dependentKey
2851
+ @param {Number} value
2852
+ @return {Ember.ComputedProperty} computed property which returns true if
2853
+ the original value for property is greater or equal then given value.
2854
+ @public
2855
+ */
2856
+
2857
+ function gte(dependentKey, value) {
2858
+ return _emberMetalComputed.computed(dependentKey, function () {
2859
+ return _emberMetalProperty_get.get(this, dependentKey) >= value;
2860
+ });
2861
+ }
2862
+
2863
+ /**
2864
+ A computed property that returns true if the provided dependent property
2865
+ is less than the provided value.
2723
2866
 
2724
- this.set('firstName', name[0]);
2725
- this.set('lastName', name[1]);
2867
+ Example
2726
2868
 
2727
- return value;
2728
- }
2729
- }.property('firstName', 'lastName')
2869
+ ```javascript
2870
+ var Hamster = Ember.Object.extend({
2871
+ needsMoreBananas: Ember.computed.lt('numBananas', 3)
2730
2872
  });
2731
2873
 
2732
- var person = Person.create();
2874
+ var hamster = Hamster.create();
2733
2875
 
2734
- person.set('fullName', 'Peter Wagenet');
2735
- person.get('firstName'); // 'Peter'
2736
- person.get('lastName'); // 'Wagenet'
2876
+ hamster.get('needsMoreBananas'); // true
2877
+ hamster.set('numBananas', 3);
2878
+ hamster.get('needsMoreBananas'); // false
2879
+ hamster.set('numBananas', 2);
2880
+ hamster.get('needsMoreBananas'); // true
2737
2881
  ```
2738
2882
 
2739
- @class ComputedProperty
2740
- @namespace Ember
2741
- @constructor
2883
+ @method lt
2884
+ @for Ember.computed
2885
+ @param {String} dependentKey
2886
+ @param {Number} value
2887
+ @return {Ember.ComputedProperty} computed property which returns true if
2888
+ the original value for property is less then given value.
2742
2889
  @public
2743
2890
  */
2744
- function ComputedProperty(config, opts) {
2745
- this.isDescriptor = true;
2746
- if (typeof config === "function") {
2747
- config.__ember_arity = config.length;
2748
- this._getter = config;
2749
- if (config.__ember_arity > 1) {
2750
- _emberMetalCore["default"].deprecate("Using the same function as getter and setter is deprecated.", false, {
2751
- url: "http://emberjs.com/deprecations/v1.x/#toc_deprecate-using-the-same-function-as-getter-and-setter-in-computed-properties"
2752
- });
2753
- this._setter = config;
2754
- }
2755
- } else {
2756
- this._getter = config.get;
2757
- this._setter = config.set;
2758
- if (this._setter && this._setter.__ember_arity === undefined) {
2759
- this._setter.__ember_arity = this._setter.length;
2760
- }
2761
- }
2762
-
2763
- this._dependentKeys = undefined;
2764
- this._suspended = undefined;
2765
- this._meta = undefined;
2766
2891
 
2767
- _emberMetalCore["default"].deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable'));
2768
- this._cacheable = opts && opts.cacheable !== undefined ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone.
2769
- this._dependentKeys = opts && opts.dependentKeys;
2770
- _emberMetalCore["default"].deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. You can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty('readOnly'));
2771
- this._readOnly = opts && (opts.readOnly !== undefined || !!opts.readOnly) || false; // TODO: Set always to `false` once this deprecation is gone.
2892
+ function lt(dependentKey, value) {
2893
+ return _emberMetalComputed.computed(dependentKey, function () {
2894
+ return _emberMetalProperty_get.get(this, dependentKey) < value;
2895
+ });
2772
2896
  }
2773
2897
 
2774
- ComputedProperty.prototype = new _emberMetalProperties.Descriptor();
2775
-
2776
- var ComputedPropertyPrototype = ComputedProperty.prototype;
2777
-
2778
2898
  /**
2779
- Properties are cacheable by default. Computed property will automatically
2780
- cache the return value of your function until one of the dependent keys changes.
2899
+ A computed property that returns true if the provided dependent property
2900
+ is less than or equal to the provided value.
2781
2901
 
2782
- Call `volatile()` to set it into non-cached mode. When in this mode
2783
- the computed property will not automatically cache the return value.
2902
+ Example
2784
2903
 
2785
- However, if a property is properly observable, there is no reason to disable
2786
- caching.
2904
+ ```javascript
2905
+ var Hamster = Ember.Object.extend({
2906
+ needsMoreBananas: Ember.computed.lte('numBananas', 3)
2907
+ });
2787
2908
 
2788
- @method cacheable
2789
- @param {Boolean} aFlag optional set to `false` to disable caching
2790
- @return {Ember.ComputedProperty} this
2791
- @chainable
2792
- @deprecated All computed properties are cacheble by default. Use `volatile()` instead to opt-out to caching.
2909
+ var hamster = Hamster.create();
2910
+
2911
+ hamster.get('needsMoreBananas'); // true
2912
+ hamster.set('numBananas', 5);
2913
+ hamster.get('needsMoreBananas'); // false
2914
+ hamster.set('numBananas', 3);
2915
+ hamster.get('needsMoreBananas'); // true
2916
+ ```
2917
+
2918
+ @method lte
2919
+ @for Ember.computed
2920
+ @param {String} dependentKey
2921
+ @param {Number} value
2922
+ @return {Ember.ComputedProperty} computed property which returns true if
2923
+ the original value for property is less or equal than given value.
2793
2924
  @public
2794
2925
  */
2795
- ComputedPropertyPrototype.cacheable = function (aFlag) {
2796
- _emberMetalCore["default"].deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.');
2797
- this._cacheable = aFlag !== false;
2798
- return this;
2799
- };
2926
+
2927
+ function lte(dependentKey, value) {
2928
+ return _emberMetalComputed.computed(dependentKey, function () {
2929
+ return _emberMetalProperty_get.get(this, dependentKey) <= value;
2930
+ });
2931
+ }
2800
2932
 
2801
2933
  /**
2802
- Call on a computed property to set it into non-cached mode. When in this
2803
- mode the computed property will not automatically cache the return value.
2934
+ A computed property that performs a logical `and` on the
2935
+ original values for the provided dependent properties.
2936
+
2937
+ Example
2804
2938
 
2805
2939
  ```javascript
2806
- var outsideService = Ember.Object.extend({
2807
- value: function() {
2808
- return OutsideService.getValue();
2809
- }.property().volatile()
2810
- }).create();
2940
+ var Hamster = Ember.Object.extend({
2941
+ readyForCamp: Ember.computed.and('hasTent', 'hasBackpack')
2942
+ });
2943
+
2944
+ var hamster = Hamster.create();
2945
+
2946
+ hamster.get('readyForCamp'); // false
2947
+ hamster.set('hasTent', true);
2948
+ hamster.get('readyForCamp'); // false
2949
+ hamster.set('hasBackpack', true);
2950
+ hamster.get('readyForCamp'); // true
2951
+ hamster.set('hasBackpack', 'Yes');
2952
+ hamster.get('readyForCamp'); // 'Yes'
2811
2953
  ```
2812
2954
 
2813
- @method volatile
2814
- @return {Ember.ComputedProperty} this
2815
- @chainable
2955
+ @method and
2956
+ @for Ember.computed
2957
+ @param {String} dependentKey*
2958
+ @return {Ember.ComputedProperty} computed property which performs
2959
+ a logical `and` on the values of all the original values for properties.
2816
2960
  @public
2817
2961
  */
2818
- ComputedPropertyPrototype["volatile"] = function () {
2819
- this._cacheable = false;
2820
- return this;
2821
- };
2962
+ var and = generateComputedWithProperties(function (properties) {
2963
+ var value;
2964
+ for (var key in properties) {
2965
+ value = properties[key];
2966
+ if (properties.hasOwnProperty(key) && !value) {
2967
+ return false;
2968
+ }
2969
+ }
2970
+ return value;
2971
+ });
2822
2972
 
2973
+ exports.and = and;
2823
2974
  /**
2824
- Call on a computed property to set it into read-only mode. When in this
2825
- mode the computed property will throw an error when set.
2975
+ A computed property which performs a logical `or` on the
2976
+ original values for the provided dependent properties.
2977
+
2978
+ Example
2826
2979
 
2827
2980
  ```javascript
2828
- var Person = Ember.Object.extend({
2829
- guid: function() {
2830
- return 'guid-guid-guid';
2831
- }.property().readOnly()
2981
+ var Hamster = Ember.Object.extend({
2982
+ readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella')
2832
2983
  });
2833
2984
 
2834
- var person = Person.create();
2985
+ var hamster = Hamster.create();
2835
2986
 
2836
- person.set('guid', 'new-guid'); // will throw an exception
2987
+ hamster.get('readyForRain'); // false
2988
+ hamster.set('hasUmbrella', true);
2989
+ hamster.get('readyForRain'); // true
2990
+ hamster.set('hasJacket', 'Yes');
2991
+ hamster.get('readyForRain'); // 'Yes'
2837
2992
  ```
2838
2993
 
2839
- @method readOnly
2840
- @return {Ember.ComputedProperty} this
2841
- @chainable
2994
+ @method or
2995
+ @for Ember.computed
2996
+ @param {String} dependentKey*
2997
+ @return {Ember.ComputedProperty} computed property which performs
2998
+ a logical `or` on the values of all the original values for properties.
2842
2999
  @public
2843
3000
  */
2844
- ComputedPropertyPrototype.readOnly = function (readOnly) {
2845
- _emberMetalCore["default"].deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0);
2846
- this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone
2847
- _emberMetalCore["default"].assert("Computed properties that define a setter using the new syntax cannot be read-only", !(this._readOnly && this._setter && this._setter !== this._getter));
2848
- return this;
2849
- };
3001
+ var or = generateComputedWithProperties(function (properties) {
3002
+ for (var key in properties) {
3003
+ if (properties.hasOwnProperty(key) && properties[key]) {
3004
+ return properties[key];
3005
+ }
3006
+ }
3007
+ return false;
3008
+ });
2850
3009
 
3010
+ exports.or = or;
2851
3011
  /**
2852
- Sets the dependent keys on this computed property. Pass any number of
2853
- arguments containing key paths that this computed property depends on.
3012
+ A computed property that returns the first truthy value
3013
+ from a list of dependent properties.
2854
3014
 
2855
- ```javascript
2856
- var President = Ember.Object.extend({
2857
- fullName: computed(function() {
2858
- return this.get('firstName') + ' ' + this.get('lastName');
3015
+ Example
2859
3016
 
2860
- // Tell Ember that this computed property depends on firstName
2861
- // and lastName
2862
- }).property('firstName', 'lastName')
3017
+ ```javascript
3018
+ var Hamster = Ember.Object.extend({
3019
+ hasClothes: Ember.computed.any('hat', 'shirt')
2863
3020
  });
2864
3021
 
2865
- var president = President.create({
2866
- firstName: 'Barack',
2867
- lastName: 'Obama'
2868
- });
3022
+ var hamster = Hamster.create();
2869
3023
 
2870
- president.get('fullName'); // 'Barack Obama'
3024
+ hamster.get('hasClothes'); // null
3025
+ hamster.set('shirt', 'Hawaiian Shirt');
3026
+ hamster.get('hasClothes'); // 'Hawaiian Shirt'
2871
3027
  ```
2872
3028
 
2873
- @method property
2874
- @param {String} path* zero or more property paths
2875
- @return {Ember.ComputedProperty} this
2876
- @chainable
3029
+ @method any
3030
+ @for Ember.computed
3031
+ @param {String} dependentKey*
3032
+ @return {Ember.ComputedProperty} computed property which returns
3033
+ the first truthy value of given list of properties.
3034
+ @deprecated Use `Ember.computed.or` instead.
2877
3035
  @public
2878
3036
  */
2879
- ComputedPropertyPrototype.property = function () {
2880
- var args;
2881
-
2882
- var addArg = function (property) {
2883
- _emberMetalCore["default"].deprecate("Depending on arrays using a dependent key ending with `@each` is deprecated. " + ("Please refactor from `Ember.computed('" + property + "', function() {});` to `Ember.computed('" + property.slice(0, -6) + ".[]', function() {})`."), property.slice(-5) !== '@each', { id: 'ember-metal.@each-dependent-key-leaf', until: '2.0.0' });
2884
-
2885
- args.push(property);
2886
- };
2887
-
2888
- args = [];
2889
- for (var i = 0, l = arguments.length; i < l; i++) {
2890
- _emberMetalExpand_properties["default"](arguments[i], addArg);
3037
+ var any = generateComputedWithProperties(function (properties) {
3038
+ _emberMetalCore["default"].deprecate('Usage of Ember.computed.any is deprecated, use `Ember.computed.or` instead.');
3039
+ for (var key in properties) {
3040
+ if (properties.hasOwnProperty(key) && properties[key]) {
3041
+ return properties[key];
3042
+ }
2891
3043
  }
3044
+ return null;
3045
+ });
2892
3046
 
2893
- this._dependentKeys = args;
2894
- return this;
2895
- };
2896
-
3047
+ exports.any = any;
2897
3048
  /**
2898
- In some cases, you may want to annotate computed properties with additional
2899
- metadata about how they function or what values they operate on. For example,
2900
- computed property functions may close over variables that are then no longer
2901
- available for introspection.
3049
+ A computed property that returns the array of values
3050
+ for the provided dependent properties.
2902
3051
 
2903
- You can pass a hash of these values to a computed property like this:
3052
+ Example
2904
3053
 
2905
- ```
2906
- person: function() {
2907
- var personId = this.get('personId');
2908
- return App.Person.create({ id: personId });
2909
- }.property().meta({ type: App.Person })
2910
- ```
3054
+ ```javascript
3055
+ var Hamster = Ember.Object.extend({
3056
+ clothes: Ember.computed.collect('hat', 'shirt')
3057
+ });
2911
3058
 
2912
- The hash that you pass to the `meta()` function will be saved on the
2913
- computed property descriptor under the `_meta` key. Ember runtime
2914
- exposes a public API for retrieving these values from classes,
2915
- via the `metaForProperty()` function.
3059
+ var hamster = Hamster.create();
2916
3060
 
2917
- @method meta
2918
- @param {Object} meta
2919
- @chainable
3061
+ hamster.get('clothes'); // [null, null]
3062
+ hamster.set('hat', 'Camp Hat');
3063
+ hamster.set('shirt', 'Camp Shirt');
3064
+ hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
3065
+ ```
3066
+
3067
+ @method collect
3068
+ @for Ember.computed
3069
+ @param {String} dependentKey*
3070
+ @return {Ember.ComputedProperty} computed property which maps
3071
+ values of all passed in properties to an array.
2920
3072
  @public
2921
3073
  */
2922
-
2923
- ComputedPropertyPrototype.meta = function (meta) {
2924
- if (arguments.length === 0) {
2925
- return this._meta || {};
2926
- } else {
2927
- this._meta = meta;
2928
- return this;
2929
- }
2930
- };
2931
-
2932
- /* impl descriptor API */
2933
- ComputedPropertyPrototype.didChange = function (obj, keyName) {
2934
- // _suspended is set via a CP.set to ensure we don't clear
2935
- // the cached value set by the setter
2936
- if (this._cacheable && this._suspended !== obj) {
2937
- var meta = metaFor(obj);
2938
- if (meta.cache && meta.cache[keyName] !== undefined) {
2939
- meta.cache[keyName] = undefined;
2940
- _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
3074
+ var collect = generateComputedWithProperties(function (properties) {
3075
+ var res = _emberMetalCore["default"].A();
3076
+ for (var key in properties) {
3077
+ if (properties.hasOwnProperty(key)) {
3078
+ if (_emberMetalIs_none["default"](properties[key])) {
3079
+ res.push(null);
3080
+ } else {
3081
+ res.push(properties[key]);
3082
+ }
2941
3083
  }
2942
3084
  }
2943
- };
2944
-
2945
- function finishChains(chainNodes) {
2946
- for (var i = 0, l = chainNodes.length; i < l; i++) {
2947
- chainNodes[i].didChange(null);
2948
- }
2949
- }
3085
+ return res;
3086
+ });
2950
3087
 
3088
+ exports.collect = collect;
2951
3089
  /**
2952
- Access the value of the function backing the computed property.
2953
- If this property has already been cached, return the cached result.
2954
- Otherwise, call the function passing the property name as an argument.
3090
+ Creates a new property that is an alias for another property
3091
+ on an object. Calls to `get` or `set` this property behave as
3092
+ though they were called on the original property.
2955
3093
 
2956
3094
  ```javascript
2957
3095
  var Person = Ember.Object.extend({
2958
- fullName: function(keyName) {
2959
- // the keyName parameter is 'fullName' in this case.
2960
- return this.get('firstName') + ' ' + this.get('lastName');
2961
- }.property('firstName', 'lastName')
3096
+ name: 'Alex Matchneer',
3097
+ nomen: Ember.computed.alias('name')
2962
3098
  });
2963
3099
 
3100
+ var alex = Person.create();
2964
3101
 
2965
- var tom = Person.create({
2966
- firstName: 'Tom',
2967
- lastName: 'Dale'
2968
- });
3102
+ alex.get('nomen'); // 'Alex Matchneer'
3103
+ alex.get('name'); // 'Alex Matchneer'
2969
3104
 
2970
- tom.get('fullName') // 'Tom Dale'
3105
+ alex.set('nomen', '@machty');
3106
+ alex.get('name'); // '@machty'
2971
3107
  ```
2972
3108
 
2973
- @method get
2974
- @param {String} keyName The key being accessed.
2975
- @return {Object} The return value of the function backing the CP.
3109
+ @method alias
3110
+ @for Ember.computed
3111
+ @param {String} dependentKey
3112
+ @return {Ember.ComputedProperty} computed property which creates an
3113
+ alias to the original value for property.
2976
3114
  @public
2977
3115
  */
2978
- ComputedPropertyPrototype.get = function (obj, keyName) {
2979
- var ret, cache, meta, chainNodes;
2980
- if (this._cacheable) {
2981
- meta = metaFor(obj);
2982
- cache = meta.cache;
2983
-
2984
- var result = cache && cache[keyName];
2985
-
2986
- if (result === UNDEFINED) {
2987
- return undefined;
2988
- } else if (result !== undefined) {
2989
- return result;
2990
- }
2991
-
2992
- ret = this._getter.call(obj, keyName);
2993
- cache = meta.cache;
2994
- if (!cache) {
2995
- cache = meta.cache = {};
2996
- }
2997
- if (ret === undefined) {
2998
- cache[keyName] = UNDEFINED;
2999
- } else {
3000
- cache[keyName] = ret;
3001
- }
3002
-
3003
- chainNodes = meta.chainWatchers && meta.chainWatchers[keyName];
3004
- if (chainNodes) {
3005
- finishChains(chainNodes);
3006
- }
3007
- _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
3008
- } else {
3009
- ret = this._getter.call(obj, keyName);
3010
- }
3011
- return ret;
3012
- };
3013
3116
 
3014
3117
  /**
3015
- Set the value of a computed property. If the function that backs your
3016
- computed property does not accept arguments then the default action for
3017
- setting would be to define the property on the current object, and set
3018
- the value of the property to the value being set.
3118
+ Where `computed.alias` aliases `get` and `set`, and allows for bidirectional
3119
+ data flow, `computed.oneWay` only provides an aliased `get`. The `set` will
3120
+ not mutate the upstream property, rather causes the current property to
3121
+ become the value set. This causes the downstream property to permanently
3122
+ diverge from the upstream property.
3019
3123
 
3020
- Generally speaking if you intend for your computed property to be set
3021
- your backing function should accept either two or three arguments.
3124
+ Example
3022
3125
 
3023
3126
  ```javascript
3024
- var Person = Ember.Object.extend({
3025
- // these will be supplied by `create`
3127
+ var User = Ember.Object.extend({
3026
3128
  firstName: null,
3027
3129
  lastName: null,
3130
+ nickName: Ember.computed.oneWay('firstName')
3131
+ });
3028
3132
 
3029
- fullName: function(key, value, oldValue) {
3030
- // getter
3031
- if (arguments.length === 1) {
3032
- var firstName = this.get('firstName');
3033
- var lastName = this.get('lastName');
3034
-
3035
- return firstName + ' ' + lastName;
3036
-
3037
- // setter
3038
- } else {
3039
- var name = value.split(' ');
3040
-
3041
- this.set('firstName', name[0]);
3042
- this.set('lastName', name[1]);
3043
-
3044
- return value;
3045
- }
3046
- }.property('firstName', 'lastName')
3133
+ var teddy = User.create({
3134
+ firstName: 'Teddy',
3135
+ lastName: 'Zeenny'
3047
3136
  });
3048
3137
 
3049
- var person = Person.create();
3050
-
3051
- person.set('fullName', 'Peter Wagenet');
3052
- person.get('firstName'); // 'Peter'
3053
- person.get('lastName'); // 'Wagenet'
3138
+ teddy.get('nickName'); // 'Teddy'
3139
+ teddy.set('nickName', 'TeddyBear'); // 'TeddyBear'
3140
+ teddy.get('firstName'); // 'Teddy'
3054
3141
  ```
3055
3142
 
3056
- @method set
3057
- @param {String} keyName The key being accessed.
3058
- @param {Object} newValue The new value being assigned.
3059
- @param {String} oldValue The old value being replaced.
3060
- @return {Object} The return value of the function backing the CP.
3143
+ @method oneWay
3144
+ @for Ember.computed
3145
+ @param {String} dependentKey
3146
+ @return {Ember.ComputedProperty} computed property which creates a
3147
+ one way computed property to the original value for property.
3061
3148
  @public
3062
3149
  */
3063
- ComputedPropertyPrototype.set = function computedPropertySetWithSuspend(obj, keyName, value) {
3064
- var oldSuspended = this._suspended;
3065
-
3066
- this._suspended = obj;
3067
-
3068
- try {
3069
- this._set(obj, keyName, value);
3070
- } finally {
3071
- this._suspended = oldSuspended;
3072
- }
3073
- };
3074
-
3075
- ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) {
3076
- var cacheable = this._cacheable;
3077
- var setter = this._setter;
3078
- var meta = metaFor(obj, cacheable);
3079
- var cache = meta.cache;
3080
- var hadCachedValue = false;
3081
-
3082
- var cachedValue, ret;
3083
-
3084
- if (this._readOnly) {
3085
- throw new _emberMetalError["default"]("Cannot set read-only property \"" + keyName + "\" on object: " + _emberMetalUtils.inspect(obj));
3086
- }
3087
-
3088
- if (cacheable && cache && cache[keyName] !== undefined) {
3089
- if (cache[keyName] !== UNDEFINED) {
3090
- cachedValue = cache[keyName];
3091
- }
3092
-
3093
- hadCachedValue = true;
3094
- }
3095
-
3096
- if (!setter) {
3097
- _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue);
3098
- _emberMetalProperty_set.set(obj, keyName, value);
3099
- return;
3100
- } else if (setter.__ember_arity === 2) {
3101
- // Is there any way of deprecate this in a sensitive way?
3102
- // Maybe now that getters and setters are the prefered options we can....
3103
- ret = setter.call(obj, keyName, value);
3104
- } else {
3105
- ret = setter.call(obj, keyName, value, cachedValue);
3106
- }
3107
-
3108
- if (hadCachedValue && cachedValue === ret) {
3109
- return;
3110
- }
3111
-
3112
- var watched = meta.watching[keyName];
3113
- if (watched) {
3114
- _emberMetalProperty_events.propertyWillChange(obj, keyName);
3115
- }
3116
-
3117
- if (hadCachedValue) {
3118
- cache[keyName] = undefined;
3119
- }
3120
-
3121
- if (cacheable) {
3122
- if (!hadCachedValue) {
3123
- _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
3124
- }
3125
- if (!cache) {
3126
- cache = meta.cache = {};
3127
- }
3128
- if (ret === undefined) {
3129
- cache[keyName] = UNDEFINED;
3130
- } else {
3131
- cache[keyName] = ret;
3132
- }
3133
- }
3134
-
3135
- if (watched) {
3136
- _emberMetalProperty_events.propertyDidChange(obj, keyName);
3137
- }
3138
-
3139
- return ret;
3140
- };
3141
-
3142
- /* called before property is overridden */
3143
- ComputedPropertyPrototype.teardown = function (obj, keyName) {
3144
- var meta = metaFor(obj);
3145
-
3146
- if (meta.cache) {
3147
- if (keyName in meta.cache) {
3148
- _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
3149
- }
3150
3150
 
3151
- if (this._cacheable) {
3152
- delete meta.cache[keyName];
3153
- }
3154
- }
3151
+ function oneWay(dependentKey) {
3152
+ return _emberMetalAlias["default"](dependentKey).oneWay();
3153
+ }
3155
3154
 
3156
- return null; // no value to restore
3157
- };
3155
+ /**
3156
+ This is a more semantically meaningful alias of `computed.oneWay`,
3157
+ whose name is somewhat ambiguous as to which direction the data flows.
3158
+
3159
+ @method reads
3160
+ @for Ember.computed
3161
+ @param {String} dependentKey
3162
+ @return {Ember.ComputedProperty} computed property which creates a
3163
+ one way computed property to the original value for property.
3164
+ @public
3165
+ */
3158
3166
 
3159
3167
  /**
3160
- This helper returns a new property descriptor that wraps the passed
3161
- computed property function. You can use this helper to define properties
3162
- with mixins or via `Ember.defineProperty()`.
3168
+ Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides
3169
+ a readOnly one way binding. Very often when using `computed.oneWay` one does
3170
+ not also want changes to propagate back up, as they will replace the value.
3163
3171
 
3164
- The function you pass will be used to both get and set property values.
3165
- The function should accept two parameters, key and value. If value is not
3166
- undefined you should set the value first. In either case return the
3167
- current value of the property.
3172
+ This prevents the reverse flow, and also throws an exception when it occurs.
3168
3173
 
3169
- A computed property defined in this way might look like this:
3174
+ Example
3170
3175
 
3171
- ```js
3172
- var Person = Ember.Object.extend({
3173
- firstName: 'Betty',
3174
- lastName: 'Jones',
3176
+ ```javascript
3177
+ var User = Ember.Object.extend({
3178
+ firstName: null,
3179
+ lastName: null,
3180
+ nickName: Ember.computed.readOnly('firstName')
3181
+ });
3175
3182
 
3176
- fullName: Ember.computed('firstName', 'lastName', function(key, value) {
3177
- return this.get('firstName') + ' ' + this.get('lastName');
3178
- })
3183
+ var teddy = User.create({
3184
+ firstName: 'Teddy',
3185
+ lastName: 'Zeenny'
3179
3186
  });
3180
3187
 
3181
- var client = Person.create();
3188
+ teddy.get('nickName'); // 'Teddy'
3189
+ teddy.set('nickName', 'TeddyBear'); // throws Exception
3190
+ // throw new Ember.Error('Cannot Set: nickName on: <User:ember27288>' );`
3191
+ teddy.get('firstName'); // 'Teddy'
3192
+ ```
3182
3193
 
3183
- client.get('fullName'); // 'Betty Jones'
3194
+ @method readOnly
3195
+ @for Ember.computed
3196
+ @param {String} dependentKey
3197
+ @return {Ember.ComputedProperty} computed property which creates a
3198
+ one way computed property to the original value for property.
3199
+ @since 1.5.0
3200
+ @public
3201
+ */
3202
+
3203
+ function readOnly(dependentKey) {
3204
+ return _emberMetalAlias["default"](dependentKey).readOnly();
3205
+ }
3206
+
3207
+ /**
3208
+ A computed property that acts like a standard getter and setter,
3209
+ but returns the value at the provided `defaultPath` if the
3210
+ property itself has not been set to a value
3184
3211
 
3185
- client.set('lastName', 'Fuller');
3186
- client.get('fullName'); // 'Betty Fuller'
3187
- ```
3212
+ Example
3188
3213
 
3189
- _Note: This is the preferred way to define computed properties when writing third-party
3190
- libraries that depend on or use Ember, since there is no guarantee that the user
3191
- will have prototype extensions enabled._
3214
+ ```javascript
3215
+ var Hamster = Ember.Object.extend({
3216
+ wishList: Ember.computed.defaultTo('favoriteFood')
3217
+ });
3192
3218
 
3193
- You might use this method if you disabled
3194
- [Prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/).
3195
- The alternative syntax might look like this
3196
- (if prototype extensions are enabled, which is the default behavior):
3219
+ var hamster = Hamster.create({ favoriteFood: 'Banana' });
3197
3220
 
3198
- ```js
3199
- fullName: function () {
3200
- return this.get('firstName') + ' ' + this.get('lastName');
3201
- }.property('firstName', 'lastName')
3221
+ hamster.get('wishList'); // 'Banana'
3222
+ hamster.set('wishList', 'More Unit Tests');
3223
+ hamster.get('wishList'); // 'More Unit Tests'
3224
+ hamster.get('favoriteFood'); // 'Banana'
3202
3225
  ```
3203
3226
 
3204
- @class computed
3205
- @namespace Ember
3206
- @constructor
3207
- @static
3208
- @param {String} [dependentKeys*] Optional dependent keys that trigger this computed property.
3209
- @param {Function} func The computed property function.
3210
- @return {Ember.ComputedProperty} property descriptor instance
3227
+ @method defaultTo
3228
+ @for Ember.computed
3229
+ @param {String} defaultPath
3230
+ @return {Ember.ComputedProperty} computed property which acts like
3231
+ a standard getter and setter, but defaults to the value from `defaultPath`.
3232
+ @deprecated Use `Ember.computed.oneWay` or custom CP with default instead.
3211
3233
  @public
3212
3234
  */
3213
- function computed(func) {
3214
- var args;
3215
-
3216
- if (arguments.length > 1) {
3217
- args = [].slice.call(arguments);
3218
- func = args.pop();
3219
- }
3220
-
3221
- var cp = new ComputedProperty(func);
3222
3235
 
3223
- if (args) {
3224
- cp.property.apply(cp, args);
3225
- }
3236
+ function defaultTo(defaultPath) {
3237
+ return _emberMetalComputed.computed({
3238
+ get: function (key) {
3239
+ _emberMetalCore["default"].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
3240
+ return _emberMetalProperty_get.get(this, defaultPath);
3241
+ },
3226
3242
 
3227
- return cp;
3243
+ set: function (key, newValue, cachedValue) {
3244
+ _emberMetalCore["default"].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
3245
+ return newValue != null ? newValue : _emberMetalProperty_get.get(this, defaultPath);
3246
+ }
3247
+ });
3228
3248
  }
3229
3249
 
3230
3250
  /**
3231
- Returns the cached value for a property, if one exists.
3232
- This can be useful for peeking at the value of a computed
3233
- property that is generated lazily, without accidentally causing
3234
- it to be created.
3251
+ Creates a new property that is an alias for another property
3252
+ on an object. Calls to `get` or `set` this property behave as
3253
+ though they were called on the original property, but also
3254
+ print a deprecation warning.
3235
3255
 
3236
- @method cacheFor
3237
- @for Ember
3238
- @param {Object} obj the object whose property you want to check
3239
- @param {String} key the name of the property whose cached value you want
3240
- to return
3241
- @return {Object} the cached value
3256
+ @method deprecatingAlias
3257
+ @for Ember.computed
3258
+ @param {String} dependentKey
3259
+ @return {Ember.ComputedProperty} computed property which creates an
3260
+ alias with a deprecation to the original value for property.
3261
+ @since 1.7.0
3242
3262
  @public
3243
3263
  */
3244
- function cacheFor(obj, key) {
3245
- var meta = obj['__ember_meta__'];
3246
- var cache = meta && meta.cache;
3247
- var ret = cache && cache[key];
3248
3264
 
3249
- if (ret === UNDEFINED) {
3250
- return undefined;
3251
- }
3252
- return ret;
3265
+ function deprecatingAlias(dependentKey) {
3266
+ return _emberMetalComputed.computed(dependentKey, {
3267
+ get: function (key) {
3268
+ _emberMetalCore["default"].deprecate("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.");
3269
+ return _emberMetalProperty_get.get(this, dependentKey);
3270
+ },
3271
+ set: function (key, value) {
3272
+ _emberMetalCore["default"].deprecate("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.");
3273
+ _emberMetalProperty_set.set(this, dependentKey, value);
3274
+ return value;
3275
+ }
3276
+ });
3253
3277
  }
3254
-
3255
- cacheFor.set = function (cache, key, value) {
3256
- if (value === undefined) {
3257
- cache[key] = UNDEFINED;
3258
- } else {
3259
- cache[key] = value;
3260
- }
3261
- };
3262
-
3263
- cacheFor.get = function (cache, key) {
3264
- var ret = cache[key];
3265
- if (ret === UNDEFINED) {
3266
- return undefined;
3267
- }
3268
- return ret;
3269
- };
3270
-
3271
- cacheFor.remove = function (cache, key) {
3272
- cache[key] = undefined;
3273
- };
3274
-
3275
- exports.ComputedProperty = ComputedProperty;
3276
- exports.computed = computed;
3277
- exports.cacheFor = cacheFor;
3278
3278
  });
3279
3279
  enifed('ember-metal/core', ['exports'], function (exports) {
3280
3280
  /*globals Ember:true,ENV,EmberENV */
@@ -3299,7 +3299,7 @@ enifed('ember-metal/core', ['exports'], function (exports) {
3299
3299
 
3300
3300
  @class Ember
3301
3301
  @static
3302
- @version 1.13.12
3302
+ @version 1.13.13
3303
3303
  @public
3304
3304
  */
3305
3305
 
@@ -3333,11 +3333,11 @@ enifed('ember-metal/core', ['exports'], function (exports) {
3333
3333
 
3334
3334
  @property VERSION
3335
3335
  @type String
3336
- @default '1.13.12'
3336
+ @default '1.13.13'
3337
3337
  @static
3338
3338
  @public
3339
3339
  */
3340
- Ember.VERSION = '1.13.12';
3340
+ Ember.VERSION = '1.13.13';
3341
3341
 
3342
3342
  /**
3343
3343
  The hash of environment variables used to control various configuration
@@ -6980,75 +6980,6 @@ enifed("ember-metal/mixin", ["exports", "ember-metal/core", "ember-metal/merge",
6980
6980
  exports.REQUIRED = REQUIRED;
6981
6981
  });
6982
6982
  // warn, assert, wrap, et;
6983
- enifed("ember-metal/observer_set", ["exports", "ember-metal/utils", "ember-metal/events"], function (exports, _emberMetalUtils, _emberMetalEvents) {
6984
- "use strict";
6985
-
6986
- /*
6987
- this.observerSet = {
6988
- [senderGuid]: { // variable name: `keySet`
6989
- [keyName]: listIndex
6990
- }
6991
- },
6992
- this.observers = [
6993
- {
6994
- sender: obj,
6995
- keyName: keyName,
6996
- eventName: eventName,
6997
- listeners: [
6998
- [target, method, flags]
6999
- ]
7000
- },
7001
- ...
7002
- ]
7003
- */
7004
- exports["default"] = ObserverSet;
7005
-
7006
- function ObserverSet() {
7007
- this.clear();
7008
- }
7009
-
7010
- ObserverSet.prototype.add = function (sender, keyName, eventName) {
7011
- var observerSet = this.observerSet;
7012
- var observers = this.observers;
7013
- var senderGuid = _emberMetalUtils.guidFor(sender);
7014
- var keySet = observerSet[senderGuid];
7015
- var index;
7016
-
7017
- if (!keySet) {
7018
- observerSet[senderGuid] = keySet = {};
7019
- }
7020
- index = keySet[keyName];
7021
- if (index === undefined) {
7022
- index = observers.push({
7023
- sender: sender,
7024
- keyName: keyName,
7025
- eventName: eventName,
7026
- listeners: []
7027
- }) - 1;
7028
- keySet[keyName] = index;
7029
- }
7030
- return observers[index].listeners;
7031
- };
7032
-
7033
- ObserverSet.prototype.flush = function () {
7034
- var observers = this.observers;
7035
- var i, len, observer, sender;
7036
- this.clear();
7037
- for (i = 0, len = observers.length; i < len; ++i) {
7038
- observer = observers[i];
7039
- sender = observer.sender;
7040
- if (sender.isDestroying || sender.isDestroyed) {
7041
- continue;
7042
- }
7043
- _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners);
7044
- }
7045
- };
7046
-
7047
- ObserverSet.prototype.clear = function () {
7048
- this.observerSet = {};
7049
- this.observers = [];
7050
- };
7051
- });
7052
6983
  enifed("ember-metal/observer", ["exports", "ember-metal/watching", "ember-metal/array", "ember-metal/events"], function (exports, _emberMetalWatching, _emberMetalArray, _emberMetalEvents) {
7053
6984
  "use strict";
7054
6985
 
@@ -7179,6 +7110,75 @@ enifed("ember-metal/observer", ["exports", "ember-metal/watching", "ember-metal/
7179
7110
  return this;
7180
7111
  }
7181
7112
  });
7113
+ enifed("ember-metal/observer_set", ["exports", "ember-metal/utils", "ember-metal/events"], function (exports, _emberMetalUtils, _emberMetalEvents) {
7114
+ "use strict";
7115
+
7116
+ /*
7117
+ this.observerSet = {
7118
+ [senderGuid]: { // variable name: `keySet`
7119
+ [keyName]: listIndex
7120
+ }
7121
+ },
7122
+ this.observers = [
7123
+ {
7124
+ sender: obj,
7125
+ keyName: keyName,
7126
+ eventName: eventName,
7127
+ listeners: [
7128
+ [target, method, flags]
7129
+ ]
7130
+ },
7131
+ ...
7132
+ ]
7133
+ */
7134
+ exports["default"] = ObserverSet;
7135
+
7136
+ function ObserverSet() {
7137
+ this.clear();
7138
+ }
7139
+
7140
+ ObserverSet.prototype.add = function (sender, keyName, eventName) {
7141
+ var observerSet = this.observerSet;
7142
+ var observers = this.observers;
7143
+ var senderGuid = _emberMetalUtils.guidFor(sender);
7144
+ var keySet = observerSet[senderGuid];
7145
+ var index;
7146
+
7147
+ if (!keySet) {
7148
+ observerSet[senderGuid] = keySet = {};
7149
+ }
7150
+ index = keySet[keyName];
7151
+ if (index === undefined) {
7152
+ index = observers.push({
7153
+ sender: sender,
7154
+ keyName: keyName,
7155
+ eventName: eventName,
7156
+ listeners: []
7157
+ }) - 1;
7158
+ keySet[keyName] = index;
7159
+ }
7160
+ return observers[index].listeners;
7161
+ };
7162
+
7163
+ ObserverSet.prototype.flush = function () {
7164
+ var observers = this.observers;
7165
+ var i, len, observer, sender;
7166
+ this.clear();
7167
+ for (i = 0, len = observers.length; i < len; ++i) {
7168
+ observer = observers[i];
7169
+ sender = observer.sender;
7170
+ if (sender.isDestroying || sender.isDestroyed) {
7171
+ continue;
7172
+ }
7173
+ _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners);
7174
+ }
7175
+ };
7176
+
7177
+ ObserverSet.prototype.clear = function () {
7178
+ this.observerSet = {};
7179
+ this.observers = [];
7180
+ };
7181
+ });
7182
7182
  enifed('ember-metal/path_cache', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) {
7183
7183
  'use strict';
7184
7184
 
@@ -12589,6 +12589,41 @@ enifed('ember-template-compiler/system/calculate-location-display', ['exports'],
12589
12589
  return moduleInfo;
12590
12590
  }
12591
12591
  });
12592
+ enifed("ember-template-compiler/system/compile", ["exports", "ember-template-compiler/system/compile_options", "ember-template-compiler/system/template"], function (exports, _emberTemplateCompilerSystemCompile_options, _emberTemplateCompilerSystemTemplate) {
12593
+ /**
12594
+ @module ember
12595
+ @submodule ember-template-compiler
12596
+ */
12597
+
12598
+ "use strict";
12599
+
12600
+ var compile;
12601
+
12602
+ /**
12603
+ Uses HTMLBars `compile` function to process a string into a compiled template.
12604
+
12605
+ This is not present in production builds.
12606
+
12607
+ @private
12608
+ @method compile
12609
+ @param {String} templateString This is the string to be compiled by HTMLBars.
12610
+ @param {Object} options This is an options hash to augment the compiler options.
12611
+ */
12612
+
12613
+ exports["default"] = function (templateString, options) {
12614
+ if (!compile && Ember.__loader.registry['htmlbars-compiler/compiler']) {
12615
+ compile = requireModule('htmlbars-compiler/compiler').compile;
12616
+ }
12617
+
12618
+ if (!compile) {
12619
+ throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.');
12620
+ }
12621
+
12622
+ var templateSpec = compile(templateString, _emberTemplateCompilerSystemCompile_options["default"](options));
12623
+
12624
+ return _emberTemplateCompilerSystemTemplate["default"](templateSpec);
12625
+ };
12626
+ });
12592
12627
  enifed("ember-template-compiler/system/compile_options", ["exports", "ember-metal/core", "ember-metal/merge", "ember-template-compiler/plugins"], function (exports, _emberMetalCore, _emberMetalMerge, _emberTemplateCompilerPlugins) {
12593
12628
  /**
12594
12629
  @module ember
@@ -12628,7 +12663,7 @@ enifed("ember-template-compiler/system/compile_options", ["exports", "ember-meta
12628
12663
 
12629
12664
  options.buildMeta = function buildMeta(program) {
12630
12665
  return {
12631
- revision: 'Ember@1.13.12',
12666
+ revision: 'Ember@1.13.13',
12632
12667
  loc: program.loc,
12633
12668
  moduleName: options.moduleName
12634
12669
  };
@@ -12637,41 +12672,6 @@ enifed("ember-template-compiler/system/compile_options", ["exports", "ember-meta
12637
12672
  return options;
12638
12673
  };
12639
12674
  });
12640
- enifed("ember-template-compiler/system/compile", ["exports", "ember-template-compiler/system/compile_options", "ember-template-compiler/system/template"], function (exports, _emberTemplateCompilerSystemCompile_options, _emberTemplateCompilerSystemTemplate) {
12641
- /**
12642
- @module ember
12643
- @submodule ember-template-compiler
12644
- */
12645
-
12646
- "use strict";
12647
-
12648
- var compile;
12649
-
12650
- /**
12651
- Uses HTMLBars `compile` function to process a string into a compiled template.
12652
-
12653
- This is not present in production builds.
12654
-
12655
- @private
12656
- @method compile
12657
- @param {String} templateString This is the string to be compiled by HTMLBars.
12658
- @param {Object} options This is an options hash to augment the compiler options.
12659
- */
12660
-
12661
- exports["default"] = function (templateString, options) {
12662
- if (!compile && Ember.__loader.registry['htmlbars-compiler/compiler']) {
12663
- compile = requireModule('htmlbars-compiler/compiler').compile;
12664
- }
12665
-
12666
- if (!compile) {
12667
- throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.');
12668
- }
12669
-
12670
- var templateSpec = compile(templateString, _emberTemplateCompilerSystemCompile_options["default"](options));
12671
-
12672
- return _emberTemplateCompilerSystemTemplate["default"](templateSpec);
12673
- };
12674
- });
12675
12675
  enifed('ember-template-compiler/system/precompile', ['exports', 'ember-template-compiler/system/compile_options'], function (exports, _emberTemplateCompilerSystemCompile_options) {
12676
12676
  /**
12677
12677
  @module ember
@@ -14484,7 +14484,7 @@ enifed("htmlbars-runtime/hooks", ["exports", "./render", "../morph-range/morph-l
14484
14484
  return {
14485
14485
  meta: template.meta,
14486
14486
  arity: template.arity,
14487
- yield: yieldArgs,
14487
+ "yield": yieldArgs,
14488
14488
  yieldItem: yieldItem(template, env, scope, morph, renderState, visitor),
14489
14489
  yieldIn: yieldInShadowTemplate(template, env, scope, morph, renderState, visitor),
14490
14490
  raw: template,
@@ -14720,7 +14720,7 @@ enifed("htmlbars-runtime/hooks", ["exports", "./render", "../morph-range/morph-l
14720
14720
  function thisFor(options) {
14721
14721
  return {
14722
14722
  arity: options.template.arity,
14723
- yield: options.template.yield,
14723
+ "yield": options.template["yield"],
14724
14724
  yieldItem: options.template.yieldItem,
14725
14725
  yieldIn: options.template.yieldIn
14726
14726
  };
@@ -15207,7 +15207,7 @@ enifed("htmlbars-runtime/hooks", ["exports", "./render", "../morph-range/morph-l
15207
15207
  return true;
15208
15208
  },
15209
15209
 
15210
- yield: function (morph, env, scope, params, hash, template, inverse, visitor) {
15210
+ "yield": function (morph, env, scope, params, hash, template, inverse, visitor) {
15211
15211
  // the current scope is provided purely for the creation of shadow
15212
15212
  // scopes; it should not be provided to user code.
15213
15213