vendor/assets/javascripts/ember-datastore.js in rasputin-0.11.1 vs vendor/assets/javascripts/ember-datastore.js in rasputin-0.11.3
- old
+ new
@@ -1,14 +1,12 @@
(function(exports) {
// ==========================================================================
-// Project: SproutCore IndexSet
+// Project: Ember IndexSet
// Copyright: ©2011 Strobe Inc. and contributors.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-/*globals sc_assert */
-
var get = Ember.get, set = Ember.set, abs = Math.abs;
function isIndexSet(obj) {
return obj instanceof Ember.IndexSet;
}
@@ -97,11 +95,10 @@
@extends Ember.Enumerable
@extends Ember.MutableEnumerable
@extends Ember.Copyable
@extends Ember.Freezable
- @since SproutCore 1.0
*/
Ember.IndexSet = Ember.Object.extend(Ember.Enumerable, Ember.MutableEnumerable, Ember.Freezable, Ember.Copyable,
/** @scope Ember.IndexSet.prototype */ {
/**
@@ -1053,11 +1050,11 @@
match is the only one
@returns {Ember.IndexSet} receiver
*/
addObject: function(object, firstOnly) {
var source = get(this, 'source');
- sc_assert("%@.addObject() requires source".fmt(this), !!source);
+ ember_assert("%@.addObject() requires source".fmt(this), !!source);
var len = get(source, 'length'),
cur = 0, idx;
while(cur>=0 && cur<len) {
@@ -1100,11 +1097,11 @@
match is the only one
@returns {Ember.IndexSet} receiver
*/
removeObject: function(object, firstOnly) {
var source = get(this, 'source');
- sc_assert("%@.removeObject() requires source".fmt(this), !!source);
+ ember_assert("%@.removeObject() requires source".fmt(this), !!source);
var len = source.get('length'),
cur = 0, idx;
while(cur>=0 && cur<len) {
@@ -1238,22 +1235,19 @@
})({});
(function(exports) {
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
/**
@class
@@ -1290,19 +1284,19 @@
You can give an order, which the resulting records should follow, like this:
q = Ember.Query.create({
conditions: "firstName = 'Jonny' AND lastName = 'Cash'",
recordType: MyApp.MyModel,
- orderBy: "lastName, year DEEmber"
+ orderBy: "lastName, year DESC"
});
The default order direction is ascending. You can change it to descending
- by writing `'DEEmber'` behind the property name like in the example above.
+ by writing `'DESC'` behind the property name like in the example above.
If no order is given, or records are equal in respect to a given order,
records will be ordered by guid.
- SproutCore Query Language
+ Ember Query Language
=====
Features of the query language:
Primitives:
@@ -1383,11 +1377,11 @@
TODO add examples
@extends Ember.Object
@extends Ember.Copyable
@extends Ember.Freezable
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.Query = Ember.Object.extend(Ember.Copyable, Ember.Freezable,
/** @scope Ember.Query.prototype */ {
@@ -1410,11 +1404,11 @@
*/
conditions: null,
/**
Optional orderBy parameters. This can be a string of keys, optionally
- beginning with the strings `"DEEmber "` or `"AEmber "` to select descending or
+ beginning with the strings `"DESC "` or `"ASC "` to select descending or
ascending order.
Alternatively, you can specify a comparison function, in which case the
two records will be sent to it. Your comparison function, as with any
other, is expected to return -1, 0, or 1.
@@ -2156,12 +2150,11 @@
if (t.delimeted) skipThisCharacter = true;
// reserved words
if ( !t.delimeted ) {
for ( var anotherToken in grammar ) {
- if ( grammar[anotherToken].reservedWord
- && anotherToken == tokenValue ) {
+ if ( grammar[anotherToken].reservedWord && anotherToken == tokenValue ) {
tokenType = anotherToken;
}
}
}
@@ -2338,12 +2331,11 @@
}
function tokenIsMissingChilds (position) {
var p = position;
if ( p < 0 ) return true;
- return (expectedType('left',p) && !l[p].leftSide)
- || (expectedType('right',p) && !l[p].rightSide);
+ return (expectedType('left',p) && !l[p].leftSide) || (expectedType('right',p) && !l[p].rightSide);
}
function typesAreMatching (parent, child) {
var side = (child < parent) ? 'left' : 'right';
if ( parent < 0 || child < 0 ) return false;
@@ -2449,11 +2441,11 @@
var p = o[i];
p = p.replace(/^\s+|\s+$/,'');
p = p.replace(/\s+/,',');
p = p.split(',');
o[i] = {propertyName: p[0]};
- if (p[1] && p[1] == 'DEEmber') o[i].descending = true;
+ if (p[1] && p[1] == 'DESC') o[i].descending = true;
}
return o;
}
@@ -2763,25 +2755,23 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-// @global Ember
-
var get = Ember.get, set = Ember.set;
/**
@class
An error, used to represent an error state.
- Many API's within SproutCore will return an instance of this object whenever
+ Many API's within Ember will return an instance of this object whenever
they have an error occur. An error includes an error code, description,
and optional human readable label that indicates the item that failed.
Depending on the error, other properties may also be added to the object
to help you recover from the failure.
@@ -2798,11 +2788,11 @@
set isError to YES, then calling Ember.ok(obj) on your object will return NO.
If isError is YES, then Ember.val(obj) will return your errorValue property
instead of the receiver.
@extends Ember.Object
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.StoreError = Ember.Object.extend(
/** @scope Ember.StoreError.prototype */ {
/**
@@ -2855,11 +2845,11 @@
Walk like a duck.
@type Boolean
*/
isError: YES
-}) ;
+});
/**
Creates a new Ember.StoreError instance with the passed description, label, and
code. All parameters are optional.
@@ -2871,12 +2861,12 @@
Ember.StoreError.desc = function(description, label, value, code) {
var opts = { message: description } ;
if (label !== undefined) opts.label = label ;
if (code !== undefined) opts.code = code ;
if (value !== undefined) opts.errorValue = value ;
- return this.create(opts) ;
-} ;
+ return this.create(opts);
+};
/**
Shorthand form of the Ember.StoreError.desc method.
@param description {String} human readable description of the error
@@ -2885,11 +2875,11 @@
@returns {Ember.StoreError} new error instance.
*/
Ember.$error = function(description, label, value, c) {
return Ember.StoreError.desc(description,label, value, c);
-} ;
+};
/**
Returns NO if the passed value is an error object or false.
@param {Object} ret object value
@@ -2931,28 +2921,25 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
var get = Ember.get, set = Ember.set, none = Ember.none, copy = Ember.copy, K;
/**
@class
- A Record is the core model class in SproutCore. It is analogous to
+ A Record is the core model class in Ember. It is analogous to
NSManagedObject in Core Data and EOEnterpriseObject in the Enterprise
Objects Framework (aka WebObjects), or ActiveRecord::Base in Rails.
- To create a new model class, in your SproutCore workspace, do:
+ To create a new model class, in your Ember workspace, do:
$ sc-gen model MyApp.MyModel
This will create MyApp.MyModel in clients/my_app/models/my_model.js.
@@ -2969,11 +2956,11 @@
You can bulk update attributes from the server using the
`updateAttributes()` method.
@extends Ember.Object
@see Ember.RecordAttribute
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.Record = Ember.Object.extend(
/** @scope Ember.Record.prototype */ {
/**
@@ -4409,18 +4396,15 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
/** @class
A RecordAttribute describes a single attribute on a record. It is used to
@@ -4455,11 +4439,11 @@
@extends Ember.Object
@see Ember.Record
@see Ember.ManyAttribute
@see Ember.SingleAttribute
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.RecordAttribute = Ember.Object.extend(
/** @scope Ember.RecordAttribute.prototype */ {
/**
Walk like a duck.
@@ -4584,11 +4568,11 @@
while(klass && !(ret = transforms[Ember.guidFor(klass)])) {
// check if super has create property to detect Ember.Object's
if(klass.superclass && klass.superclass.hasOwnProperty('create')) {
klass = klass.superclass ;
}
-
+
// otherwise return the function transform handler
else klass = 'function' ;
}
return ret ;
@@ -4624,11 +4608,11 @@
context = {
record: record,
key: key
};
- for(i = 0; i < len; i++) Ember.addObserver(value, children[i], this, this._EmberRA_childObserver, context);
+ for(i = 0; i < len; i++) Ember.addObserver(value, children[i], this, this._SCRA_childObserver, context);
}
}
return value ;
},
@@ -4649,11 +4633,11 @@
@param {Object} obj The transformed value that is being observed
@param {String} key The key used to access this attribute on the record
@param {Object} prev Previous value (not used)
@param {Object} context Hash of extra context information
*/
- _EmberRA_childObserver: function(obj, key, prev, context) {
+ _SCRA_childObserver: function(obj, key, prev, context) {
// write the new value back to the record
this.call(context.record, context.key, obj);
// mark the attribute as dirty
context.record.notifyPropertyChange(context.key);
@@ -4733,15 +4717,15 @@
this._super();
// setup some internal properties needed for KVO - faking 'cacheable'
this.cacheKey = "__cache__" + Ember.guidFor(this) ;
this.lastSetValueKey = "__lastValue__" + Ember.guidFor(this) ;
},
-
- /**
- @private
-
- Returns a computed property value that can be assigned directly to a
+
+ /**
+ @private
+
+ Returns a computed property value that can be assigned directly to a
property on a record for this attribute.
*/
computed: function() {
var attr = this;
var ret = Ember.computed(function(key, value) {
@@ -4814,16 +4798,16 @@
@returns {Ember.RecordAttribute} receiver
*/
registerTransform: function(klass, transform) {
Ember.RecordAttribute.transforms[Ember.guidFor(klass)] = transform;
},
-
+
/**
- Retrieves the original record attribute for the passed key. You can't
- use get() to retrieve record attributes because that will invoke the
+ Retrieves the original record attribute for the passed key. You can't
+ use get() to retrieve record attributes because that will invoke the
property instead.
-
+
@param {Ember.Record} rec record instance to inspect
@param {String} keyName key name to retrieve
@returns {Ember.RecordAttribute} the attribute or null if none defined
*/
attrFor: function(rec, keyName) {
@@ -4859,11 +4843,11 @@
/** @private -
convert an arbitrary object value to a String
allow null through as that will be checked separately
*/
to: function(obj) {
- if (!(typeof obj === 'string') && !Ember.none(obj) && obj.toString) {
+ if ((typeof obj !== 'string') && !Ember.none(obj) && obj.toString) {
obj = obj.toString();
}
return obj;
}
});
@@ -4884,11 +4868,11 @@
/** @private - generic converter for Object */
Ember.RecordAttribute.registerTransform(Object, {
/** @private - check if obj is an object */
to: function(obj) {
- if (!(typeof obj === 'object') && !Ember.none(obj)) {
+ if ((typeof obj !== 'object') && !Ember.none(obj)) {
obj = {};
}
return obj;
}
});
@@ -5054,17 +5038,15 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2010 Evin Grano
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
var get = Ember.get, set = Ember.set;
/** @class
ChildAttribute is a subclass of `RecordAttribute` and handles to-one
@@ -5076,14 +5058,13 @@
There are many ways you can configure a ManyAttribute:
contacts: Ember.ChildAttribute.attr('Ember.Child');
@extends Ember.RecordAttribute
- @since SproutCore 1.0
+ @since Ember 1.0
*/
-Ember.ChildAttribute = Ember.RecordAttribute.extend(
- /** @scope Ember.ChildAttribute.prototype */ {
+Ember.ChildAttribute = Ember.RecordAttribute.extend({
isNestedRecordTransform: YES,
// ..........................................................
// LOW-LEVEL METHODS
@@ -5164,11 +5145,11 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember - JavaScript Application Framework
// Copyright: ©2010 Evin Grano
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
@@ -5179,11 +5160,11 @@
A `ChildArray` is used to map an array of `ChildRecord` objects.
@extends Ember.Enumerable
@extends Ember.Array
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.ChildArray = Ember.Object.extend(Ember.Enumerable, Ember.Array, Ember.MutableEnumerable, Ember.MutableArray,
/** @scope Ember.ChildArray.prototype */ {
@@ -5358,11 +5339,11 @@
recs = recs || [];
recs.forEach( function(me, idx) {
if (me instanceof Ember.Record) {
store = get(me, 'store');
sk = get(me, 'storeKey');
- if (sk) recs[idx] = store.readDataHash(sk);
+ if (sk) { recs[idx] = store.readDataHash(sk); }
}
});
return recs;
},
@@ -5370,11 +5351,11 @@
/**
Calls normalize on each object in the array
*/
normalize: function(){
this.forEach(function(child,id){
- if(child.normalize) child.normalize();
+ if (child.normalize) { child.normalize(); }
});
},
// ..........................................................
// INTERNAL SUPPORT
@@ -5439,63 +5420,56 @@
init: function() {
this._super();
this.recordPropertyDidChange();
}
-}) ;
+});
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2010 Evin Grano
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
-
-
var get = Ember.get, set = Ember.set;
/** @class
-
- ChildrenAttribute is a subclass of ChildAttribute and handles to-many
+
+ ChildrenAttribute is a subclass of ChildAttribute and handles to-many
relationships for child records.
-
+
When setting ( `set()` ) the value of a toMany attribute, make sure
to pass in an array of Ember.Record objects.
-
+
There are many ways you can configure a ChildrenAttribute:
-
+
contacts: Ember.ChildrenAttribute.attr('Ember.Child');
-
+
@extends Ember.RecordAttribute
- @since SproutCore 1.0
+ @since Ember 1.0
*/
-Ember.ChildrenAttribute = Ember.ChildAttribute.extend(
- /** @scope Ember.ChildrenAttribute.prototype */ {
-
+Ember.ChildrenAttribute = Ember.ChildAttribute.extend({
+
// ..........................................................
// LOW-LEVEL METHODS
//
-
+
/** @private - adapted for to many relationship */
toType: function(record, key, value) {
var attrKey = get(this, 'key') || key,
arrayKey = '__kidsArray__'+Ember.guidFor(this),
ret = record[arrayKey],
recordType = get(this, 'typeClass'), rel;
- // lazily create a ManyArray one time. after that always return the
+ // lazily create a ManyArray one time. after that always return the
// same object.
if (!ret) {
- ret = Ember.ChildArray.create({
+ ret = Ember.ChildArray.create({
record: record,
propertyName: attrKey,
defaultRecordType: recordType
});
@@ -5505,21 +5479,21 @@
rel.push(ret); // make sure we get notified of changes...
}
return ret;
},
-
+
// Default fromType is just returning itself
fromType: function(record, key, value){
- var sk, store,
+ var sk, store,
arrayKey = '__kidsArray__'+Ember.guidFor(this),
ret = record[arrayKey];
if (record) {
record.writeAttribute(key, value);
if (ret) ret = ret.recordPropertyDidChange();
}
-
+
return ret;
}
});
@@ -5527,16 +5501,15 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
var get = Ember.get, set = Ember.set, attrFor = Ember.RecordAttribute.attrFor;
/**
@class
@@ -5547,11 +5520,11 @@
property will be an instance of `ManyArray`. You can generally customize the
behavior of ManyArray by passing settings to the `toMany()` helper.
@extends Ember.Enumerable
@extends Ember.Array
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.ManyArray = Ember.Object.extend(Ember.Enumerable, Ember.MutableEnumerable, Ember.MutableArray, Ember.Array,
/** @scope Ember.ManyArray.prototype */ {
@@ -5992,26 +5965,22 @@
init: function() {
this._super();
this.recordPropertyDidChange();
}
-}) ;
+});
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
var get = Ember.get, set = Ember.set;
/** @class
ManyAttribute is a subclass of `RecordAttribute` and handles to-many
@@ -6029,11 +5998,11 @@
isEditable: YES|NO, make editable or not,
through: 'taggings' // set a relationship this goes through
});
@extends Ember.RecordAttribute
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.ManyAttribute = Ember.RecordAttribute.extend(
/** @scope Ember.ManyAttribute.prototype */ {
/**
@@ -6158,17 +6127,15 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
var get = Ember.get, set = Ember.set;
var RecordAttribute_call = get(Ember.RecordAttribute, 'proto').call;
var attrFor = Ember.RecordAttribute.attrFor;
/** @class
@@ -6184,11 +6151,11 @@
transform: function(), // transforms value <=> storeKey,
isEditable: YES|NO, make editable or not
});
@extends Ember.RecordAttribute
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.SingleAttribute = Ember.RecordAttribute.extend(
/** @scope Ember.SingleAttribute.prototype */ {
/**
@@ -6320,31 +6287,25 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore DataStore
+// Project: Ember DataStore
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
-
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
/**
Indicates a value has a mixed state of both on and off.
@property {String}
*/
@@ -6367,11 +6328,11 @@
// implement the data source API...
});
## Connect to a Data Source
- New SproutCore applications are wired up to fixtures as their data source.
+ New Ember applications are wired up to fixtures as their data source.
When you are ready to connect to a server, swap the use of fixtures with a
call to the desired data source.
In core.js:
@@ -6543,13 +6504,13 @@
is used by data sources when handling remote queries. This method is similar to
`dataSourceDidFetchQuery()`, except that you also provide an array of storeKeys
(or a promise to provide store keys) that comprises the result set.
@extend Ember.Object
- @since SproutCore 1.0
+ @since Ember DataStore 0.9
*/
-Ember.DataSource = Ember.Object.extend( /** @scope Ember.DataSource.prototype */ {
+Ember.DataSource = Ember.Object.extend({
// ..........................................................
// Ember.STORE ENTRY POINTS
//
@@ -6619,11 +6580,11 @@
@param {Ember.Store} store the requesting store
@param {Ember.Query} query query describing the request
@returns {Boolean} YES if you can handle fetching the query, NO otherwise
*/
fetch: function(store, query) {
- return NO ; // do not handle anything!
+ return NO; // do not handle anything!
},
/**
Called by the store whenever it needs to load a specific set of store
keys. The default implementation will call retrieveRecord() for each
@@ -6787,23 +6748,23 @@
invokes the named action for each store key. returns proper value
*/
_handleEach: function(store, storeKeys, action, ids, params) {
var len = storeKeys.length, idx, ret, cur, idOrParams;
- for(idx=0;idx<len;idx++) {
+ for (idx=0;idx<len;idx++) {
idOrParams = ids ? ids[idx] : params;
cur = action.call(this, store, storeKeys[idx], idOrParams);
if (ret === undefined) {
ret = cur ;
} else if (ret === YES) {
- ret = (cur === YES) ? YES : Ember.MIXED_STATE ;
+ ret = (cur === YES) ? YES : Ember.MIXED_STATE;
} else if (ret === NO) {
- ret = (cur === NO) ? NO : Ember.MIXED_STATE ;
+ ret = (cur === NO) ? NO : Ember.MIXED_STATE;
}
}
- return !Ember.none(ret) ? ret : null ;
+ return !Ember.none(ret) ? ret : null;
},
// ..........................................................
// SINGLE RECORD ACTIONS
@@ -6821,11 +6782,11 @@
@param {Hash} params to be passed down to data source. originated
from the commitRecords() call on the store
@returns {Boolean} YES if handled
*/
updateRecord: function(store, storeKey, params) {
- return NO ;
+ return NO;
},
/**
Called from `retrieveRecords()` to retrieve a single record.
@@ -6833,11 +6794,11 @@
@param {Array} storeKey key to retrieve
@param {String} id the id to retrieve
@returns {Boolean} YES if handled
*/
retrieveRecord: function(store, storeKey, id) {
- return NO ;
+ return NO;
},
/**
Called from `createdRecords()` to created a single record. This is the
most basic primitive to can implement to support creating a record.
@@ -6850,11 +6811,11 @@
@param {Hash} params to be passed down to data source. originated
from the commitRecords() call on the store
@returns {Boolean} YES if handled
*/
createRecord: function(store, storeKey, params) {
- return NO ;
+ return NO;
},
/**
Called from `destroyRecords()` to destroy a single record. This is the
most basic primitive to can implement to support destroying a record.
@@ -6867,28 +6828,25 @@
@param {Hash} params to be passed down to data source. originated
from the commitRecords() call on the store
@returns {Boolean} YES if handled
*/
destroyRecord: function(store, storeKey, params) {
- return NO ;
+ return NO;
}
});
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
var get = Ember.get, set = Ember.set;
/** @class
A cascading data source will actually forward requests onto an array of
@@ -6929,14 +6887,13 @@
In this case, the order you call from() will determine the order the request
will cascade.
@extends Ember.DataSource
- @since SproutCore 1.0
+ @since Ember 1.0
*/
-Ember.CascadeDataSource = Ember.DataSource.extend(
- /** @scope Ember.CascadeDataSource.prototype */ {
+Ember.CascadeDataSource = Ember.DataSource.extend({
/**
The data sources used by the cascade, in the order that they are to be
followed. Usually when you define the cascade, you will define this
array.
@@ -6954,11 +6911,11 @@
*/
from: function(dataSource) {
var dataSources = get(this, 'dataSources');
if (!dataSources) set(this, 'dataSources', dataSources = []);
dataSources.push(dataSource);
- return this ;
+ return this;
},
// ..........................................................
// Ember.STORE ENTRY POINTS
//
@@ -6968,66 +6925,66 @@
var sources = get(this, 'dataSources'),
len = sources ? sources.length : 0,
ret = NO,
cur, source, idx;
- for(idx=0; (ret !== YES) && idx<len; idx++) {
+ for (idx=0; (ret !== YES) && idx<len; idx++) {
source = sources.objectAt(idx);
cur = source.fetch ? source.fetch.apply(source, arguments) : NO;
ret = this._handleResponse(ret, cur);
}
- return ret ;
+ return ret;
},
/** @private - just cascades */
retrieveRecords: function(store, storeKeys, ids) {
var sources = get(this, 'dataSources'),
len = sources ? sources.length : 0,
ret = NO,
cur, source, idx;
- for(idx=0; (ret !== YES) && idx<len; idx++) {
+ for (idx=0; (ret !== YES) && idx<len; idx++) {
source = sources.objectAt(idx);
cur = source.retrieveRecords.apply(source, arguments);
ret = this._handleResponse(ret, cur);
}
- return ret ;
+ return ret;
},
/** @private - just cascades */
commitRecords: function(store, createStoreKeys, updateStoreKeys, destroyStoreKeys, params) {
var sources = get(this, 'dataSources'),
len = sources ? sources.length : 0,
ret = NO,
cur, source, idx;
- for(idx=0; (ret !== YES) && idx<len; idx++) {
+ for (idx=0; (ret !== YES) && idx<len; idx++) {
source = sources.objectAt(idx);
cur = source.commitRecords.apply(source, arguments);
ret = this._handleResponse(ret, cur);
}
- return ret ;
+ return ret;
},
/** @private - just cascades */
cancel: function(store, storeKeys) {
var sources = get(this, 'dataSources'),
len = sources ? sources.length : 0,
ret = NO,
cur, source, idx;
- for(idx=0; (ret !== YES) && idx<len; idx++) {
+ for (idx=0; (ret !== YES) && idx<len; idx++) {
source = sources.objectAt(idx);
cur = source.cancel.apply(source, arguments);
ret = this._handleResponse(ret, cur);
}
- return ret ;
+ return ret;
},
// ..........................................................
// INTERNAL SUPPORT
//
@@ -7039,52 +6996,47 @@
// if a dataSources array is defined, look for any strings and lookup
// the same on the data source. Replace.
var sources = get(this, 'dataSources'),
idx = sources ? get(sources, 'length') : 0,
source;
- while(--idx>=0) {
+ while (--idx>=0) {
source = sources[idx];
if (Ember.typeOf(source) === 'string') sources[idx] = get(this, source);
}
},
/** @private - Determine the proper return value. */
_handleResponse: function(current, response) {
if (response === YES) return YES ;
- else if (current === NO) return (response === NO) ? NO : Ember.MIXED_STATE ;
- else return Ember.MIXED_STATE ;
+ else if (current === NO) return (response === NO) ? NO : Ember.MIXED_STATE;
+ else return Ember.MIXED_STATE;
}
});
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
-
var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
/** @class
TODO: Describe Class
@extends Ember.DataSource
- @since SproutCore 1.0
+ @since Ember 1.0
*/
-Ember.FixturesDataSource = Ember.DataSource.extend(
- /** @scope Ember.FixturesDataSource.prototype */ {
+Ember.FixturesDataSource = Ember.DataSource.extend({
/**
If YES then the data source will asynchronously respond to data requests
from the server. If you plan to replace the fixture data source with a
data source that talks to a real remote server (using Ajax for example),
@@ -7188,11 +7140,11 @@
setTimeout(function() {
self._retrieveRecords(store, storeKeys);
}, latency);
} else this._retrieveRecords(store, storeKeys);
- return ret ;
+ return ret;
},
_retrieveRecords: function(store, storeKeys) {
storeKeys.forEach(function(storeKey) {
@@ -7222,11 +7174,11 @@
setTimeout(function() {
self._updateRecords(store, storeKeys);
}, latency);
} else this._updateRecords(store, storeKeys);
- return ret ;
+ return ret;
},
_updateRecords: function(store, storeKeys) {
storeKeys.forEach(function(storeKey) {
var hash = store.readDataHash(storeKey);
@@ -7251,11 +7203,11 @@
setTimeout(function() {
self._createRecords(store, storeKeys);
}, latency);
} else this._createRecords(store, storeKeys);
- return YES ;
+ return YES;
},
_createRecords: function(store, storeKeys) {
storeKeys.forEach(function(storeKey) {
var id = store.idFor(storeKey),
@@ -7288,11 +7240,11 @@
setTimeout(function() {
self._destroyRecords(store, storeKeys);
}, latency);
} else this._destroyRecords(store, storeKeys);
- return ret ;
+ return ret;
},
_destroyRecords: function(store, storeKeys) {
storeKeys.forEach(function(storeKey) {
@@ -7334,11 +7286,11 @@
}
// only load records that were not already loaded to avoid infinite loops
if (hashes && hashes.length>0) store.loadRecords(recordType, hashes);
- return this ;
+ return this;
},
/**
Generates an id for the passed record type. You can override this if
@@ -7380,11 +7332,11 @@
var id = store.idFor(storeKey),
recordType = store.recordTypeFor(storeKey),
fixtures = this.fixturesFor(recordType);
this._invalidateCachesFor(recordType, storeKey, id);
fixtures[id] = dataHash;
- return this ;
+ return this;
},
/**
Get the fixtures for the passed record type and prepare them if needed.
Return cached value when complete.
@@ -7443,11 +7395,11 @@
if (ret === NO) ret = YES ;
} else if (ret === YES) ret = Ember.MIXED_STATE ;
}
}, this);
- return ret ;
+ return ret;
},
/** @private
Invalidates any internal caches based on the recordType and optional
other parameters. Currently this only invalidates the storeKeyCache used
@@ -7459,11 +7411,11 @@
@returns {Ember.FixturesDataSource} receiver
*/
_invalidateCachesFor: function(recordType, storeKey, id) {
var cache = this._storeKeyCache;
if (cache) delete cache[Ember.guidFor(recordType)];
- return this ;
+ return this;
}
});
/**
@@ -7477,32 +7429,25 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore DataStore
+// Project: Ember DataStore
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
-
var get = Ember.get, set = Ember.set;
/**
@class
@@ -7544,11 +7489,11 @@
@extends Ember.Object
@extends Ember.Enumerable
@extends Ember.Array
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.RecordArray = Ember.Object.extend(Ember.Enumerable, Ember.Array, Ember.MutableEnumerable, Ember.MutableArray,
/** @scope Ember.RecordArray.prototype */ {
@@ -7967,22 +7912,22 @@
@param {Boolean} _flush to force it - use reload() to trigger it
@returns {Ember.RecordArray} receiver
*/
flush: function(_flush) {
-
+
// Are we already inside a flush? If so, then don't do it again, to avoid
// never-ending recursive flush calls. Instead, we'll simply mark
// ourselves as needing a flush again when we're done.
if (this._insideFlush) {
set(this, 'needsFlush', YES);
return this;
}
if (!get(this, 'needsFlush') && !_flush) return this; // nothing to do
set(this, 'needsFlush', NO); // avoid running again.
-
+
// fast exit
var query = get(this, 'query'),
store = get(this, 'store');
if (!store || !query || get(query, 'location') !== Ember.Query.LOCAL) {
return this;
@@ -8222,11 +8167,11 @@
},
_storeKeysContentWillChange: function(target, start, removedCount, addedCount) {
this.arrayContentWillChange(start, removedCount, addedCount);
},
-
+
/** @private
Invoked whenever the content of the `storeKeys` array changes. This will
dump any cached record lookup and then notify that the enumerable content
has changed.
*/
@@ -8267,20 +8212,15 @@
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-/*globals sc_assert */
-
-
-
-
var get = Ember.get, set = Ember.set, getPath = Ember.getPath, none = Ember.none;
/**
@class
@@ -8296,11 +8236,11 @@
Internally, the store will keep track of changes to your json data hashes
and manage syncing those changes with your data source. A data source may
be a server, local storage, or any other persistent code.
@extends Ember.Object
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.Store = Ember.Object.extend( /** @scope Ember.Store.prototype */ {
/**
An (optional) name of the store, which can be useful during debugging,
@@ -8408,19 +8348,17 @@
@param {Class} newStoreClass optional the class of the newly-created nested store (defaults to Ember.NestedStore)
@returns {Ember.NestedStore} new nested store chained to receiver
*/
chain: function(attrs, newStoreClass) {
if (!attrs) attrs = {};
-
+
attrs.parentStore = this;
if (!newStoreClass) newStoreClass = Ember.NestedStore;
// Ensure the passed-in class is a type of nested store.
- sc_assert("%@ is a valid class".fmt(newStoreClass),
- Ember.typeOf(newStoreClass) === 'class');
- sc_assert("%@ is a type of Ember.NestedStore".fmt(newStoreClass),
- Ember.NestedStore.detect(newStoreClass));
+ ember_assert("%@ is a valid class".fmt(newStoreClass), Ember.typeOf(newStoreClass) === 'class');
+ ember_assert("%@ is a type of Ember.NestedStore".fmt(newStoreClass), Ember.NestedStore.detect(newStoreClass));
// Replicate parent records references
attrs.childRecords = this.childRecords ? Ember.copy(this.childRecords) : {};
attrs.parentRecords = this.parentRecords ? Ember.copy(this.parentRecords) : {};
@@ -8772,15 +8710,15 @@
len = 1;
storeKey = storeKeys;
}
var that = this;
-
+
function iter(storeKey){
that.dataHashDidChange(storeKey, null, statusOnly, key);
}
-
+
for(idx=0;idx<len;idx++) {
if (isArray) storeKey = storeKeys[idx];
this.revisions[storeKey] = rev;
this._notifyRecordPropertyChange(storeKey, statusOnly, key);
@@ -9117,17 +9055,16 @@
recordType = getPath(recordType);
}
// handle passing a query...
if (id === undefined && !(recordType instanceof Ember.Record)) {
- sc_assert('Ember.Store#find() accepts only a record type of query',
- Ember.Record.detect(recordType) || recordType instanceof Ember.Query);
+ ember_assert('Ember.Store#find() accepts only a record type of query', Ember.Record.detect(recordType) || recordType instanceof Ember.Query);
if (!(recordType instanceof Ember.Query)) {
recordType = Ember.Query.local(recordType);
}
-
+
return this._findQuery(recordType, YES, YES);
// handle finding a single record
} else {
return this._findRecord(recordType, id);
@@ -9136,19 +9073,19 @@
/** @private
DEPRECATED used find() instead.
This method will accept a record type or query and return a record array
- matching the results. This method was commonly used prior to SproutCore
+ matching the results. This method was commonly used prior to Ember
1.0. It has been deprecated in favor of a single `find()` method instead.
- For compatibility, this method will continue to work in SproutCore 1.0 but
+ For compatibility, this method will continue to work in Ember 1.0 but
it will raise a warning. It will be removed in a future version of
- SproutCore.
+ Ember.
*/
findAll: function(recordType, conditions, params) {
- Ember.Logger.warn("Ember.Store#findAll() will be removed in a future version of SproutCore. Use Ember.Store#find() instead");
+ Ember.Logger.warn("Ember.Store#findAll() will be removed in a future version of Ember. Use Ember.Store#find() instead");
if (!recordType || !recordType.isQuery) {
recordType = Ember.Query.local(recordType, conditions, params);
}
@@ -9576,12 +9513,16 @@
// add/remove change log
changelog = this.changelog;
if (!changelog) changelog = this.changelog = Ember.Set.create();
- ((status & K.DIRTY) ? changelog.add(storeKey) : changelog.remove(storeKey));
- this.changelog=changelog;
+ if (status & K.DIRTY) {
+ changelog.add(storeKey);
+ } else {
+ changelog.remove(storeKey);
+ }
+ this.changelog = changelog;
// if commit records is enabled
if(get(this, 'commitRecordsAutomatically')){
Ember.run.schedule('actions', this, this.commitRecords);
}
@@ -10232,11 +10173,11 @@
for these methods apply here.
The return value will be the `storeKey` used for the push. This is often
convenient to pass into `loadQuery()`, if you are fetching a remote query.
- If you are upgrading from a pre SproutCore 1.0 application, this method
+ If you are upgrading from a pre Ember 1.0 application, this method
is the closest to the old `updateRecord()`.
@param {Ember.Record} recordType the record type
@param {Array} dataHash to update
@param {Array} id optional. if not passed lookup on the hash
@@ -10278,11 +10219,11 @@
constraints for these methods apply here.
The return value will be the storeKeys used for each push. This is often
convenient to pass into `loadQuery()`, if you are fetching a remote query.
- If you are upgrading from a pre SproutCore 1.0 application, this method
+ If you are upgrading from a pre Ember 1.0 application, this method
is the closest to the old `updateRecords()`.
@param {Ember.Record} recordTypes the record type or array of record types
@param {Array} dataHashes array of data hashes to update
@param {Array} ids optional array of ids. if not passed lookup on hashes
@@ -11051,110 +10992,20 @@
/** @private */
Ember.Store.reopen({
nextStoreIndex: 1
});
-// ..........................................................
-// COMPATIBILITY
-//
-
-/** @private
- global store is used only for deprecated compatibility methods. Don't use
- this in real code.
-*/
-Ember.Store._getDefaultStore = function() {
- var store = this._store;
- if(!store) this._store = store = Ember.Store.create();
- return store;
-};
-
-/** @private
-
- DEPRECATED
-
- Included for compatibility, loads data hashes with the named `recordType`.
- If no `recordType` is passed, expects to find a `recordType` property in the
- data hashes. `dataSource` and `isLoaded` params are ignored.
-
- Calls `Ember.Store#loadRecords()` on the default store. Do not use this method in
- new code.
-
- @param {Array} dataHashes data hashes to import
- @param {Object} dataSource ignored
- @param {Ember.Record} recordType default record type
- @param {Boolean} isLoaded ignored
- @returns {Array} Ember.Record instances for loaded data hashes
-*/
-Ember.Store.updateRecords = function(dataHashes, dataSource, recordType, isLoaded) {
-
- Ember.Logger.warn("Ember.Store.updateRecords() is deprecated. Use loadRecords() instead");
-
- var store = this._getDefaultStore(),
- len = dataHashes.length,
- idx, ret;
-
- // if no recordType was passed, build an array of recordTypes from hashes
- if (!recordType) {
- recordType = [];
- for(idx=0;idx<len;idx++) recordType[idx] = dataHashes[idx].recordType;
- }
-
- // call new API. Returns storeKeys
- ret = store.loadRecords(recordType, dataHashes);
-
- // map to Ember.Record instances
- len = ret.length;
- for(idx=0;idx<len;idx++) ret[idx] = store.materializeRecord(ret[idx]);
-
- return ret ;
-};
-
-/** @private
-
- DEPRECATED
-
- Finds a record with the passed guid on the default store. This is included
- only for compatibility. You should use the newer `find()` method defined on
- `Ember.Store` instead.
-
- @param {String} guid the guid
- @param {Ember.Record} recordType expected record type
- @returns {Ember.Record} found record
-*/
-Ember.Store.find = function(guid, recordType) {
- return this._getDefaultStore().find(recordType, guid);
-};
-
-/** @private
-
- DEPRECATED
-
- Passes through to `findAll` on default store. This is included only for
- compatibility. You should use the newer `findAll()` defined on `Ember.Store`
- instead.
-
- @param {Hash} filter search parameters
- @param {Ember.Record} recordType type of record to find
- @returns {Ember.RecordArray} result set
-*/
-Ember.Store.findAll = function(filter, recordType) {
- return this._getDefaultStore().findAll(filter, recordType);
-};
-
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore - JavaScript Application Framework
+// Project: Ember DataStore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-/*globals sc_assert */
-
var get = Ember.get, set = Ember.set;
var o_create = Ember.platform.create;
/**
@@ -11168,11 +11019,11 @@
Normally you will not create a nested store directly. Instead, you can
retrieve a nested store by using the `chain()` method. When you are finished
working with the nested store, `destroy()` will dispose of it.
@extends Ember.Store
- @since SproutCore 1.0
+ @since Ember 1.0
*/
Ember.NestedStore = Ember.Store.extend(
/** @scope Ember.NestedStore.prototype */ {
/**
@@ -11265,12 +11116,11 @@
@param {Ember.Query} query query object to use.
@returns {Ember.Record|Ember.RecordArray}
*/
find: function(query) {
- sc_assert("Ember.Store#find() can only accept LOCAL queries in nested stores",
- !query || !(query instanceof Ember.Query) || get(query, 'location') === Ember.Query.LOCAL);
+ ember_assert("Ember.Store#find() can only accept LOCAL queries in nested stores", !query || !(query instanceof Ember.Query) || get(query, 'location') === Ember.Query.LOCAL);
return this._super.apply(this, arguments);
},
/**
Propagate this store's changes to its parent. If the store does not
@@ -11425,11 +11275,11 @@
var locks = this.locks, rev, editables,
pk, pr, path, tup, obj, key;
// already locked -- nothing to do
if (locks && locks[storeKey]) return this;
-
+
// create locks if needed
if (!locks) locks = this.locks = [];
// fixup editables
editables = this.editables;
@@ -11445,13 +11295,13 @@
}
if (pstore && editState === Ember.Store.EDITABLE) {
pk = this.childRecords[storeKey];
- if (pk){
- // Since this is a nested record we have to actually walk up the
- // parent chain to get to the root parent and clone that hash. And
+ if (pk) {
+ // Since this is a nested record we have to actually walk up the
+ // parent chain to get to the root parent and clone that hash. And
// then reconstruct the memory space linking.
this._lock(pk);
pr = this.parentRecords[pk];
if (pr) {
path = pr[storeKey];
@@ -11545,11 +11395,11 @@
return this._super(storeKey, status);
},
/** @private - bookkeeping for a single data hash. */
dataHashDidChange: function(storeKeys, rev, statusOnly, key) {
-
+
// update the revision for storeKey. Use generateStoreKey() because that
// gaurantees a universally (to this store hierarchy anyway) unique
// key value.
if (!rev) rev = Ember.Store.generateStoreKey();
var isArray, len, idx, storeKey;
@@ -11754,41 +11604,29 @@
/** @private - adapt for nested store */
pushError: function(recordType, id, error, storeKey) {
throw Ember.Store.NESTED_STORE_UNSUPPORTED_ERROR;
}
-}) ;
+});
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore DataStore
+// Project: Ember DataStore
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
-
-
-
-
-
})({});
(function(exports) {
// ==========================================================================
-// Project: SproutCore DataStore
+// Project: Ember DataStore
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
-
-
-
})({});