parsejs-rails 1.2.9.1 → 1.2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5874b28efab05657c8b591ae9432ec51e87b40b2
4
- data.tar.gz: 23f8455374cf7261039e5c2e97653ec73dae1201
3
+ metadata.gz: 5827b50d046a8ea22cc0091dbe5a2a030788e3ab
4
+ data.tar.gz: 566723afa4dd6106a3a44a0b0eca9ad8c455ebfc
5
5
  SHA512:
6
- metadata.gz: c0d2095834349f728f5b36472c05d5a042b22dca5e25c622ef11d53d1b34fb42ad8675a4f8391e7ec312837b9fe7d4a1104e2d91be6b58616cb1bf5ea510b5a4
7
- data.tar.gz: 91af5eb94a7dff0dfc29b31be57ac10c8f191aebe7179e3a20560372716ad0968e02465ce6537a8add938ce3330514d373432371cd7fb4b91ba407fd666fb122
6
+ metadata.gz: aa83d1e44839f5646f6898619393fe92feef23b3acae8adacca87985b2723c7674bbf03e517dd2222554abd3c376e47baa3182793d8a47fb765b199eedb20cee
7
+ data.tar.gz: 70c8abaf741b39a0778acf8a340187e7a16ac83191d3950020b1693f830cf95dc6a185d43e683ac4cf182b788b48e7a59bcca5dbe4800c435688b9e1a810ceba
data/README.md CHANGED
@@ -4,7 +4,7 @@ The Parse Javascript SDK as an asset for Rails.
4
4
 
5
5
  This gem provides:
6
6
 
7
- - Parse Javascript SDK 1.2.9
7
+ - Parse Javascript SDK 1.2.10
8
8
 
9
9
  ## Installation
10
10
 
@@ -1,5 +1,5 @@
1
1
  module Parsejs
2
2
  module Rails
3
- VERSION = "1.2.9.1"
3
+ VERSION = "1.2.10.0"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Parse JavaScript SDK
3
- * Version: 1.2.9
4
- * Built: Tue Aug 13 2013 17:31:35
3
+ * Version: 1.2.10
4
+ * Built: Tue Sep 03 2013 14:38:42
5
5
  * http://parse.com
6
6
  *
7
7
  * Copyright 2013 Parse, Inc.
@@ -13,7 +13,7 @@
13
13
  */
14
14
  (function(root) {
15
15
  root.Parse = root.Parse || {};
16
- root.Parse.VERSION = "js1.2.9";
16
+ root.Parse.VERSION = "js1.2.10";
17
17
  }(this));
18
18
  // Underscore.js 1.4.4
19
19
  // http://underscorejs.org
@@ -1541,30 +1541,41 @@
1541
1541
  };
1542
1542
 
1543
1543
  /**
1544
- * route is classes, users, login, etc.
1545
- * objectId is null if there is no associated objectId.
1546
- * method is the http method for the REST API.
1547
- * dataObject is the payload as an object, or null if there is none.
1544
+ * Options:
1545
+ * route: is classes, users, login, etc.
1546
+ * objectId: null if there is no associated objectId.
1547
+ * method: the http method for the REST API.
1548
+ * dataObject: the payload as an object, or null if there is none.
1549
+ * useMasterKey: overrides whether to use the master key if set.
1548
1550
  * @ignore
1549
1551
  */
1550
- Parse._request = function(route, className, objectId, method, dataObject) {
1552
+ Parse._request = function(options) {
1553
+ var route = options.route;
1554
+ var className = options.className;
1555
+ var objectId = options.objectId;
1556
+ var method = options.method;
1557
+ var useMasterKey = options.useMasterKey;
1558
+ var dataObject = options.data;
1559
+
1551
1560
  if (!Parse.applicationId) {
1552
- throw "You must specify your applicationId using Parse.initialize";
1561
+ throw "You must specify your applicationId using Parse.initialize.";
1553
1562
  }
1554
1563
 
1555
1564
  if (!Parse.javaScriptKey && !Parse.masterKey) {
1556
- throw "You must specify a key using Parse.initialize";
1565
+ throw "You must specify a key using Parse.initialize.";
1557
1566
  }
1558
1567
 
1559
1568
 
1560
1569
  if (route !== "batch" &&
1561
1570
  route !== "classes" &&
1571
+ route !== "events" &&
1562
1572
  route !== "files" &&
1563
1573
  route !== "functions" &&
1564
1574
  route !== "login" &&
1565
1575
  route !== "push" &&
1566
1576
  route !== "requestPasswordReset" &&
1567
- route !== "users") {
1577
+ route !== "users" &&
1578
+ route !== "jobs") {
1568
1579
  throw "Bad route: '" + route + "'.";
1569
1580
  }
1570
1581
 
@@ -1586,8 +1597,12 @@
1586
1597
  method = "POST";
1587
1598
  }
1588
1599
 
1600
+ if (Parse._.isUndefined(useMasterKey)) {
1601
+ useMasterKey = Parse._useMasterKey;
1602
+ }
1603
+
1589
1604
  dataObject._ApplicationId = Parse.applicationId;
1590
- if (!Parse._useMasterKey) {
1605
+ if (!useMasterKey) {
1591
1606
  dataObject._JavaScriptKey = Parse.javaScriptKey;
1592
1607
  } else {
1593
1608
  dataObject._MasterKey = Parse.masterKey;
@@ -1842,6 +1857,67 @@
1842
1857
  };
1843
1858
  }(this));
1844
1859
 
1860
+ (function(root) {
1861
+ root.Parse = root.Parse || {};
1862
+ var Parse = root.Parse;
1863
+ var _ = Parse._;
1864
+
1865
+ /**
1866
+ * @namespace Provides an interface to Parse's logging and analytics backend.
1867
+ */
1868
+ Parse.Analytics = Parse.Analytics || {};
1869
+
1870
+ _.extend(Parse.Analytics, {
1871
+ /**
1872
+ * Tracks the occurrence of a custom event with additional dimensions.
1873
+ * Parse will store a data point at the time of invocation with the given
1874
+ * event name.
1875
+ *
1876
+ * Dimensions will allow segmentation of the occurrences of this custom
1877
+ * event. Keys and values should be {@code String}s, and will throw
1878
+ * otherwise.
1879
+ *
1880
+ * To track a user signup along with additional metadata, consider the
1881
+ * following:
1882
+ * <pre>
1883
+ * var dimensions = {
1884
+ * gender: 'm',
1885
+ * source: 'web',
1886
+ * dayType: 'weekend'
1887
+ * };
1888
+ * Parse.Analytics.track('signup', dimensions);
1889
+ * </pre>
1890
+ *
1891
+ * There is a default limit of 4 dimensions per event tracked.
1892
+ *
1893
+ * @param {String} name The name of the custom event to report to Parse as
1894
+ * having happened.
1895
+ * @param {Object} dimensions The dictionary of information by which to
1896
+ * segment this event.
1897
+ * @return {Parse.Promise} A promise that is resolved when the round-trip
1898
+ * to the server completes.
1899
+ */
1900
+ track: function(name, dimensions) {
1901
+ if (!name || name.trim().length === 0) {
1902
+ throw 'A name for the custom event must be provided';
1903
+ }
1904
+
1905
+ _.each(dimensions, function(val, key) {
1906
+ if (!_.isString(key) || !_.isString(val)) {
1907
+ throw 'track() dimensions expects keys and values of type "string".';
1908
+ }
1909
+ });
1910
+
1911
+ return Parse._request({
1912
+ route: 'events',
1913
+ className: name,
1914
+ method: 'POST',
1915
+ data: dimensions
1916
+ });
1917
+ }
1918
+ });
1919
+ }(this));
1920
+
1845
1921
  (function(root) {
1846
1922
  root.Parse = root.Parse || {};
1847
1923
  var Parse = root.Parse;
@@ -4088,6 +4164,8 @@
4088
4164
  * @return {Parse.Promise} Promise that is resolved when the save finishes.
4089
4165
  */
4090
4166
  save: function(options) {
4167
+ options= options || {};
4168
+
4091
4169
  var self = this;
4092
4170
  if (!self._previousSave) {
4093
4171
  self._previousSave = self._source.then(function(base64, type) {
@@ -4095,7 +4173,13 @@
4095
4173
  base64: base64,
4096
4174
  _ContentType: type
4097
4175
  };
4098
- return Parse._request("files", self._name, null, 'POST', data);
4176
+ return Parse._request({
4177
+ route: "files",
4178
+ className: self._name,
4179
+ method: 'POST',
4180
+ data: data,
4181
+ useMasterKey: options.useMasterKey
4182
+ });
4099
4183
 
4100
4184
  }).then(function(response) {
4101
4185
  self._name = response.name;
@@ -4215,12 +4299,19 @@
4215
4299
  *
4216
4300
  * @param {Array} list A list of <code>Parse.Object</code>.
4217
4301
  * @param {Object} options A Backbone-style callback object.
4302
+ * Valid options are:<ul>
4303
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
4304
+ * be used for this request.
4305
+ * </ul>
4218
4306
  */
4219
4307
  Parse.Object.saveAll = function(list, options) {
4220
- return Parse.Object._deepSaveAsync(list)._thenRunCallbacks(options);
4308
+ options = options || {};
4309
+ return Parse.Object._deepSaveAsync(list, {
4310
+ useMasterKey: options.useMasterKey
4311
+ })._thenRunCallbacks(options);
4221
4312
  };
4222
4313
 
4223
- /**
4314
+ /**
4224
4315
  * Destroy the given list of models on the server if it was already persisted.
4225
4316
  * Optimistically removes each model from its collection, if it has one.
4226
4317
  * If `wait: true` is passed, waits for the server to respond before removal.
@@ -4288,28 +4379,36 @@
4288
4379
  *
4289
4380
  * @param {Array} list A list of <code>Parse.Object</code>.
4290
4381
  * @param {Object} options A Backbone-style callback object.
4382
+ * Valid options are:<ul>
4383
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
4384
+ * be used for this request.
4385
+ * </ul>
4291
4386
  */
4292
4387
  Parse.Object.destroyAll = function(list, options) {
4293
- var promise = Parse.Promise.as();
4294
- var batch = [];
4295
- var errors = [];
4388
+ options = options || {};
4296
4389
 
4297
4390
  var triggerDestroy = function(object) {
4298
4391
  object.trigger('destroy', object, object.collection, options);
4299
4392
  };
4300
4393
 
4394
+ var errors = [];
4301
4395
  var destroyBatch = function(batch) {
4302
4396
  var promise = Parse.Promise.as();
4303
4397
 
4304
4398
  if (batch.length > 0) {
4305
4399
  promise = promise.then(function() {
4306
- return Parse._request("batch", null, null, "POST", {
4307
- requests: _.map(batch, function(object) {
4308
- return {
4309
- method: "DELETE",
4310
- path: "/1/classes/" + object.className + "/" + object.id
4311
- };
4312
- })
4400
+ return Parse._request({
4401
+ route: "batch",
4402
+ method: "POST",
4403
+ useMasterKey: options.useMasterKey,
4404
+ data: {
4405
+ requests: _.map(batch, function(object) {
4406
+ return {
4407
+ method: "DELETE",
4408
+ path: "/1/classes/" + object.className + "/" + object.id
4409
+ };
4410
+ })
4411
+ }
4313
4412
  });
4314
4413
  }).then(function(responses, status, xhr) {
4315
4414
  Parse._arrayEach(batch, function(object, i) {
@@ -4329,6 +4428,8 @@
4329
4428
  return promise;
4330
4429
  };
4331
4430
 
4431
+ var promise = Parse.Promise.as();
4432
+ var batch = [];
4332
4433
  Parse._arrayEach(list, function(object, i) {
4333
4434
  if (!object.id || !options.wait) {
4334
4435
  triggerDestroy(object);
@@ -4986,13 +5087,22 @@
4986
5087
  * Valid options are:<ul>
4987
5088
  * <li>success: A Backbone-style success callback.
4988
5089
  * <li>error: An Backbone-style error callback.
5090
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
5091
+ * be used for this request.
4989
5092
  * </ul>
4990
5093
  * @return {Parse.Promise} A promise that is fulfilled when the fetch
4991
5094
  * completes.
4992
5095
  */
4993
5096
  fetch: function(options) {
4994
5097
  var self = this;
4995
- var request = Parse._request("classes", this.className, this.id, 'GET');
5098
+ options = options || {};
5099
+ var request = Parse._request({
5100
+ method: 'GET',
5101
+ route: "classes",
5102
+ className: this.className,
5103
+ objectId: this.id,
5104
+ useMasterKey: options.useMasterKey
5105
+ });
4996
5106
  return request.then(function(response, status, xhr) {
4997
5107
  self._finishFetch(self.parse(response, status, xhr), true);
4998
5108
  return self;
@@ -5040,6 +5150,8 @@
5040
5150
  * <li>silent: Set to true to avoid firing the `set` event.
5041
5151
  * <li>success: A Backbone-style success callback.
5042
5152
  * <li>error: An Backbone-style error callback.
5153
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
5154
+ * be used for this request.
5043
5155
  * </ul>
5044
5156
  * @return {Parse.Promise} A promise that is fulfilled when the save
5045
5157
  * completes.
@@ -5107,7 +5219,9 @@
5107
5219
  unsavedChildren,
5108
5220
  unsavedFiles);
5109
5221
  if (unsavedChildren.length + unsavedFiles.length > 0) {
5110
- return Parse.Object._deepSaveAsync(this.attributes).then(function() {
5222
+ return Parse.Object._deepSaveAsync(this.attributes, {
5223
+ useMasterKey: options.useMasterKey
5224
+ }).then(function() {
5111
5225
  return model.save(null, options);
5112
5226
  }, function(error) {
5113
5227
  return Parse.Promise.error(error)._thenRunCallbacks(options, model);
@@ -5130,7 +5244,14 @@
5130
5244
  route = "users";
5131
5245
  className = null;
5132
5246
  }
5133
- var request = Parse._request(route, className, model.id, method, json);
5247
+ var request = Parse._request({
5248
+ route: route,
5249
+ className: className,
5250
+ objectId: model.id,
5251
+ method: method,
5252
+ useMasterKey: options.useMasterKey,
5253
+ data: json
5254
+ });
5134
5255
 
5135
5256
  request = request.then(function(resp, status, xhr) {
5136
5257
  var serverAttrs = model.parse(resp, status, xhr);
@@ -5166,6 +5287,8 @@
5166
5287
  * deletion of the object before triggering the `destroy` event.
5167
5288
  * <li>success: A Backbone-style success callback
5168
5289
  * <li>error: An Backbone-style error callback.
5290
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
5291
+ * be used for this request.
5169
5292
  * </ul>
5170
5293
  * @return {Parse.Promise} A promise that is fulfilled when the destroy
5171
5294
  * completes.
@@ -5186,8 +5309,13 @@
5186
5309
  triggerDestroy();
5187
5310
  }
5188
5311
 
5189
- var request =
5190
- Parse._request("classes", this.className, this.id, 'DELETE');
5312
+ var request = Parse._request({
5313
+ route: "classes",
5314
+ className: this.className,
5315
+ objectId: this.id,
5316
+ method: 'DELETE',
5317
+ useMasterKey: options.useMasterKey
5318
+ });
5191
5319
  return request.then(function() {
5192
5320
  if (options.wait) {
5193
5321
  triggerDestroy();
@@ -5563,7 +5691,11 @@
5563
5691
  return canBeSerializedAsValue;
5564
5692
  };
5565
5693
 
5566
- Parse.Object._deepSaveAsync = function(object) {
5694
+ /**
5695
+ * @param {Object} object The root object.
5696
+ * @param {Object} options: The only valid option is useMasterKey.
5697
+ */
5698
+ Parse.Object._deepSaveAsync = function(object, options) {
5567
5699
  var unsavedChildren = [];
5568
5700
  var unsavedFiles = [];
5569
5701
  Parse.Object._findUnsavedChildren(object, unsavedChildren, unsavedFiles);
@@ -5571,7 +5703,7 @@
5571
5703
  var promise = Parse.Promise.as();
5572
5704
  _.each(unsavedFiles, function(file) {
5573
5705
  promise = promise.then(function() {
5574
- return file.save();
5706
+ return file.save(options);
5575
5707
  });
5576
5708
  });
5577
5709
 
@@ -5619,26 +5751,30 @@
5619
5751
 
5620
5752
  // Save a single batch, whether previous saves succeeded or failed.
5621
5753
  return readyToStart._continueWith(function() {
5622
- return Parse._request("batch", null, null, "POST", {
5623
- requests: _.map(batch, function(object) {
5624
- var json = object._getSaveJSON();
5625
- var method = "POST";
5626
-
5627
- var path = "/1/classes/" + object.className;
5628
- if (object.id) {
5629
- path = path + "/" + object.id;
5630
- method = "PUT";
5631
- }
5632
-
5633
- object._startSave();
5634
-
5635
- return {
5636
- method: method,
5637
- path: path,
5638
- body: json
5639
- };
5640
- })
5641
-
5754
+ return Parse._request({
5755
+ route: "batch",
5756
+ method: "POST",
5757
+ useMasterKey: options.useMasterKey,
5758
+ data: {
5759
+ requests: _.map(batch, function(object) {
5760
+ var json = object._getSaveJSON();
5761
+ var method = "POST";
5762
+
5763
+ var path = "/1/classes/" + object.className;
5764
+ if (object.id) {
5765
+ path = path + "/" + object.id;
5766
+ method = "PUT";
5767
+ }
5768
+
5769
+ object._startSave();
5770
+
5771
+ return {
5772
+ method: method,
5773
+ path: path,
5774
+ body: json
5775
+ };
5776
+ })
5777
+ }
5642
5778
  }).then(function(response, status, xhr) {
5643
5779
  var error;
5644
5780
  Parse._arrayEach(batch, function(object, i) {
@@ -6073,8 +6209,10 @@
6073
6209
  * Valid options are:<ul>
6074
6210
  * <li>silent: Set to true to avoid firing `add` or `reset` events for
6075
6211
  * models fetched by this fetch.
6076
- * <li>success: A Backbone-style success callback
6212
+ * <li>success: A Backbone-style success callback.
6077
6213
  * <li>error: An Backbone-style error callback.
6214
+ * <li>useMasterKey: In Cloud Code and Node only, uses the Master Key for
6215
+ * this request.
6078
6216
  * </ul>
6079
6217
  */
6080
6218
  fetch: function(options) {
@@ -6084,7 +6222,9 @@
6084
6222
  }
6085
6223
  var collection = this;
6086
6224
  var query = this.query || new Parse.Query(this.model);
6087
- return query.find().then(function(results) {
6225
+ return query.find({
6226
+ useMasterKey: options.useMasterKey
6227
+ }).then(function(results) {
6088
6228
  if (options.add) {
6089
6229
  collection.add(results, options);
6090
6230
  } else {
@@ -6104,10 +6244,12 @@
6104
6244
  * @param {Object} options An optional object with Backbone-style options.
6105
6245
  * Valid options are:<ul>
6106
6246
  * <li>wait: Set to true to wait for the server to confirm creation of the
6107
- * model before adding it to the collection.
6247
+ * model before adding it to the collection.
6108
6248
  * <li>silent: Set to true to avoid firing an `add` event.
6109
- * <li>success: A Backbone-style success callback
6249
+ * <li>success: A Backbone-style success callback.
6110
6250
  * <li>error: An Backbone-style error callback.
6251
+ * <li>useMasterKey: In Cloud Code and Node only, uses the Master Key for
6252
+ * this request.
6111
6253
  * </ul>
6112
6254
  */
6113
6255
  create: function(model, options) {
@@ -6757,7 +6899,13 @@
6757
6899
  */
6758
6900
  logIn: function(options) {
6759
6901
  var model = this;
6760
- var request = Parse._request("login", null, null, "GET", this.toJSON());
6902
+ options = options || {};
6903
+ var request = Parse._request({
6904
+ route: "login",
6905
+ method: "GET",
6906
+ useMasterKey: options.useMasterKey,
6907
+ data: this.toJSON()
6908
+ });
6761
6909
  return request.then(function(resp, status, xhr) {
6762
6910
  var serverAttrs = model.parse(resp, status, xhr);
6763
6911
  model._finishFetch(serverAttrs);
@@ -6965,9 +7113,13 @@
6965
7113
  * @param {Object} options A Backbone-style options object.
6966
7114
  */
6967
7115
  requestPasswordReset: function(email, options) {
6968
- var json = { email: email };
6969
- var request = Parse._request("requestPasswordReset", null, null, "POST",
6970
- json);
7116
+ options = options || {};
7117
+ var request = Parse._request({
7118
+ route: "requestPasswordReset",
7119
+ method: "POST",
7120
+ useMasterKey: options.useMasterKey,
7121
+ data: { email: email }
7122
+ });
6971
7123
  return request._thenRunCallbacks(options);
6972
7124
  },
6973
7125
 
@@ -7218,15 +7370,28 @@
7218
7370
  * Either options.success or options.error is called when the find
7219
7371
  * completes.
7220
7372
  *
7221
- * @param {Object} options A Backbone-style options object.
7373
+ * @param {Object} options A Backbone-style options object. Valid options
7374
+ * are:<ul>
7375
+ * <li>success: Function to call when the find completes successfully.
7376
+ * <li>error: Function to call when the find fails.
7377
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
7378
+ * be used for this request.
7379
+ * </ul>
7380
+ *
7222
7381
  * @return {Parse.Promise} A promise that is resolved with the results when
7223
7382
  * the query completes.
7224
7383
  */
7225
7384
  find: function(options) {
7226
7385
  var self = this;
7386
+ options = options || {};
7227
7387
 
7228
- var request = Parse._request("classes", this.className, null, "GET",
7229
- this.toJSON());
7388
+ var request = Parse._request({
7389
+ route: "classes",
7390
+ className: this.className,
7391
+ method: "GET",
7392
+ useMasterKey: options.useMasterKey,
7393
+ data: this.toJSON()
7394
+ });
7230
7395
 
7231
7396
  return request.then(function(response) {
7232
7397
  return _.map(response.results, function(json) {
@@ -7247,16 +7412,31 @@
7247
7412
  * Either options.success or options.error is called when the count
7248
7413
  * completes.
7249
7414
  *
7250
- * @param {Object} options A Backbone-style options object.
7415
+ * @param {Object} options A Backbone-style options object. Valid options
7416
+ * are:<ul>
7417
+ * <li>success: Function to call when the count completes successfully.
7418
+ * <li>error: Function to call when the find fails.
7419
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
7420
+ * be used for this request.
7421
+ * </ul>
7422
+ *
7251
7423
  * @return {Parse.Promise} A promise that is resolved with the count when
7252
7424
  * the query completes.
7253
7425
  */
7254
7426
  count: function(options) {
7427
+ var self = this;
7428
+ options = options || {};
7429
+
7255
7430
  var params = this.toJSON();
7256
7431
  params.limit = 0;
7257
7432
  params.count = 1;
7258
- var request = Parse._request("classes", this.className, null, "GET",
7259
- params);
7433
+ var request = Parse._request({
7434
+ route: "classes",
7435
+ className: self.className,
7436
+ method: "GET",
7437
+ useMasterKey: options.useMasterKey,
7438
+ data: params
7439
+ });
7260
7440
 
7261
7441
  return request.then(function(response) {
7262
7442
  return response.count;
@@ -7269,17 +7449,30 @@
7269
7449
  * Either options.success or options.error is called when it completes.
7270
7450
  * success is passed the object if there is one. otherwise, undefined.
7271
7451
  *
7272
- * @param {Object} options A Backbone-style options object.
7452
+ * @param {Object} options A Backbone-style options object. Valid options
7453
+ * are:<ul>
7454
+ * <li>success: Function to call when the find completes successfully.
7455
+ * <li>error: Function to call when the find fails.
7456
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
7457
+ * be used for this request.
7458
+ * </ul>
7459
+ *
7273
7460
  * @return {Parse.Promise} A promise that is resolved with the object when
7274
7461
  * the query completes.
7275
7462
  */
7276
7463
  first: function(options) {
7277
7464
  var self = this;
7465
+ options = options || {};
7278
7466
 
7279
7467
  var params = this.toJSON();
7280
7468
  params.limit = 1;
7281
- var request = Parse._request("classes", this.className, null, "GET",
7282
- params);
7469
+ var request = Parse._request({
7470
+ route: "classes",
7471
+ className: this.className,
7472
+ method: "GET",
7473
+ useMasterKey: options.useMasterKey,
7474
+ data: params
7475
+ });
7283
7476
 
7284
7477
  return request.then(function(response) {
7285
7478
  return _.map(response.results, function(json) {
@@ -7341,6 +7534,10 @@
7341
7534
  * @return {Parse.Query} Returns the query, so you can chain this call.
7342
7535
  */
7343
7536
  equalTo: function(key, value) {
7537
+ if (_.isUndefined(value)) {
7538
+ return this.doesNotExist(key);
7539
+ }
7540
+
7344
7541
  this._where[key] = Parse._encode(value);
7345
7542
  return this;
7346
7543
  },
@@ -8424,8 +8621,15 @@
8424
8621
  * of the function.
8425
8622
  */
8426
8623
  run: function(name, data, options) {
8427
- var request = Parse._request("functions", name, null, 'POST',
8428
- Parse._encode(data, null, true));
8624
+ options = options || {};
8625
+
8626
+ var request = Parse._request({
8627
+ route: "functions",
8628
+ className: name,
8629
+ method: 'POST',
8630
+ useMasterKey: options.useMasterKey,
8631
+ data: Parse._encode(data, null, true)
8632
+ });
8429
8633
 
8430
8634
  return request.then(function(resp) {
8431
8635
  return Parse._decode(null, resp).result;
@@ -8467,6 +8671,8 @@
8467
8671
  * failed.
8468
8672
  */
8469
8673
  Parse.Push.send = function(data, options) {
8674
+ options = options || {};
8675
+
8470
8676
  if (data.where) {
8471
8677
  data.where = data.where.toJSON().where;
8472
8678
  }
@@ -8483,7 +8689,12 @@
8483
8689
  throw "Both expiration_time and expiration_time_interval can't be set";
8484
8690
  }
8485
8691
 
8486
- var request = Parse._request('push', null, null, 'POST', data);
8692
+ var request = Parse._request({
8693
+ route: 'push',
8694
+ method: 'POST',
8695
+ data: data,
8696
+ useMasterKey: options.useMasterKey
8697
+ });
8487
8698
  return request._thenRunCallbacks(options);
8488
8699
  };
8489
8700
  }(this));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsejs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9.1
4
+ version: 1.2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Macintosh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-17 00:00:00.000000000 Z
11
+ date: 2013-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties