backbone-relational-rails 0.8.8 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YTRmNmM3YWRjY2Q2NzU3YzAyMzNlNzY2MzY2MzE4ZWU5NDI4YzZmNA==
5
- data.tar.gz: !binary |-
6
- ZGUwOTE4MDEyZWU0MGJlYzQ5NmM1NTgyZjQyOWU2YTZlMmVjZmQzYg==
2
+ SHA1:
3
+ metadata.gz: de5400657b78386efd19c290e62ed5d2df7635c8
4
+ data.tar.gz: 5bfa9656cb2e4d3c0595802d67db79736373b19a
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Mzc2M2Q2MzZlMTZjMTQ3ODAyMTdkMzIzYTBjOTgxMmNkZjlkMzFkZDI2MWRl
10
- N2Q4NTQyYzg1NGM3NTk3YzQzNTllNTExNTc1NDRlNTQ1MWJkMGQ3NjdlMDlk
11
- NDM4YzRiOTQwZmIzMDJlNWI3N2IzMzhiYTYwNGNiZmQzNzM2MGM=
12
- data.tar.gz: !binary |-
13
- MDIxNTlhYjA5MTYzYzI0NDM4YWQ2M2VjYTFiNjVmYTUxZDg3NjU1NTllMTIw
14
- NTUxNzk0Mjc2YWJhNzcxMmUzYzU5Mjk4MjVkMDE4ODY5MTE4N2VkNjY0ODA4
15
- ZDkwZjEzNTM4NGEzOWQ0NjlmNzU4Mzg1YjlhNjRlYzhkMTk5ZWE=
6
+ metadata.gz: 1f02bab2dfbe65002c786cdcaa66526c76d4f7ae3af2cad4942b3b1f995ea5ae325366cfc5596ae71a915bf0c4d2fcc91384da705d0b3b678f7973225a9600c7
7
+ data.tar.gz: 5da615e1d9b60a0d0c03d84559441cf91341d571b5c719ec3d36b36bdcbb7625f331fd4e89946a11febc1b10cd7115ee9276339c8b97dfb091ccd0614f9a9d43
data/README.md CHANGED
@@ -18,7 +18,7 @@ Add the following directive to your Javascript manifest file (application.js):
18
18
 
19
19
  ## Versioning
20
20
 
21
- backbone-relational-rails 0.8.8 == Backbone-relational 0.8.8
21
+ backbone-relational-rails 0.9.0 == Backbone-relational 0.9.0
22
22
 
23
23
  Every attempt is made to mirror the currently shipping Backbone-relational version number wherever possible.
24
24
  The major, minor, and patch version numbers will always represent the Backbone-relational version. Should a gem
@@ -1,7 +1,7 @@
1
1
  module Backbone
2
2
  module Relational
3
3
  module Rails
4
- VERSION = "0.8.8"
4
+ VERSION = "0.9.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */
2
2
  /**
3
- * Backbone-relational.js 0.8.8
4
- * (c) 2011-2013 Paul Uithol and contributors (https://github.com/PaulUithol/Backbone-relational/graphs/contributors)
3
+ * Backbone-relational.js 0.9.0
4
+ * (c) 2011-2014 Paul Uithol and contributors (https://github.com/PaulUithol/Backbone-relational/graphs/contributors)
5
5
  *
6
6
  * Backbone-relational may be freely distributed under the MIT license; see the accompanying LICENSE.txt.
7
7
  * For details and documentation: https://github.com/PaulUithol/Backbone-relational.
@@ -182,7 +182,7 @@
182
182
  initializeRelation: function( model, relation, options ) {
183
183
  var type = !_.isString( relation.type ) ? relation.type : Backbone[ relation.type ] || this.getObjectByName( relation.type );
184
184
  if ( type && type.prototype instanceof Backbone.Relation ) {
185
- new type( model, relation, options ); // Also pushes the new Relation into `model._relations`
185
+ var rel = new type( model, relation, options ); // Also pushes the new Relation into `model._relations`
186
186
  }
187
187
  else {
188
188
  Backbone.Relational.showWarnings && typeof console !== 'undefined' && console.warn( 'Relation=%o; missing or invalid relation type!', relation );
@@ -326,7 +326,7 @@
326
326
  return;
327
327
  }
328
328
 
329
- new relation.type( model, relation );
329
+ var rel = new relation.type( model, relation );
330
330
  }, this );
331
331
  },
332
332
 
@@ -594,6 +594,12 @@
594
594
 
595
595
  this.relatedModel = this.options.relatedModel;
596
596
 
597
+ // No 'relatedModel' is interpreted as self-referential
598
+ if ( _.isUndefined( this.relatedModel ) ) {
599
+ this.relatedModel = this.model;
600
+ }
601
+
602
+ // Otherwise, try to resolve the given value to an object
597
603
  if ( _.isFunction( this.relatedModel ) && !( this.relatedModel.prototype instanceof Backbone.RelationalModel ) ) {
598
604
  this.relatedModel = _.result( this, 'relatedModel' );
599
605
  }
@@ -601,6 +607,7 @@
601
607
  this.relatedModel = Backbone.Relational.store.getObjectByName( this.relatedModel );
602
608
  }
603
609
 
610
+
604
611
  if ( !this.checkPreconditions() ) {
605
612
  return;
606
613
  }
@@ -619,7 +626,7 @@
619
626
 
620
627
  if ( instance ) {
621
628
  var contentKey = this.keySource;
622
- if ( contentKey !== this.key && typeof this.instance.get( this.key ) === 'object' ) {
629
+ if ( contentKey !== this.key && _.isObject( this.instance.get( this.key ) ) ) {
623
630
  contentKey = this.key;
624
631
  }
625
632
 
@@ -637,13 +644,13 @@
637
644
  this.initialize( opts );
638
645
 
639
646
  if ( this.options.autoFetch ) {
640
- this.instance.fetchRelated( this.key, _.isObject( this.options.autoFetch ) ? this.options.autoFetch : {} );
647
+ this.instance.getAsync( this.key, _.isObject( this.options.autoFetch ) ? this.options.autoFetch : {} );
641
648
  }
642
649
 
643
650
  // When 'relatedModel' are created or destroyed, check if it affects this relation.
644
651
  this.listenTo( this.instance, 'destroy', this.destroy )
645
652
  .listenTo( this.relatedCollection, 'relational:add relational:change:id', this.tryAddRelated )
646
- .listenTo( this.relatedCollection, 'relational:remove', this.removeRelated )
653
+ .listenTo( this.relatedCollection, 'relational:remove', this.removeRelated );
647
654
  }
648
655
  };
649
656
  // Fix inheritance :\
@@ -741,14 +748,21 @@
741
748
  getReverseRelations: function( model ) {
742
749
  var reverseRelations = [];
743
750
  // Iterate over 'model', 'this.related.models' (if this.related is a Backbone.Collection), or wrap 'this.related' in an array.
744
- var models = !_.isUndefined( model ) ? [ model ] : this.related && ( this.related.models || [ this.related ] );
745
- _.each( models || [], function( related ) {
746
- _.each( related.getRelations() || [], function( relation ) {
751
+ var models = !_.isUndefined( model ) ? [ model ] : this.related && ( this.related.models || [ this.related ] ),
752
+ relations = null,
753
+ relation = null;
754
+
755
+ for( var i = 0; i < ( models || [] ).length; i++ ) {
756
+ relations = models[ i ].getRelations() || [];
757
+
758
+ for( var j = 0; j < relations.length; j++ ) {
759
+ relation = relations[ j ];
760
+
747
761
  if ( this._isReverseRelation( relation ) ) {
748
762
  reverseRelations.push( relation );
749
763
  }
750
- }, this );
751
- }, this );
764
+ }
765
+ }
752
766
 
753
767
  return reverseRelations;
754
768
  },
@@ -1001,8 +1015,10 @@
1001
1015
  var toAdd = [];
1002
1016
 
1003
1017
  _.each( this.keyContents, function( attributes ) {
1018
+ var model = null;
1019
+
1004
1020
  if ( attributes instanceof this.relatedModel ) {
1005
- var model = attributes;
1021
+ model = attributes;
1006
1022
  }
1007
1023
  else {
1008
1024
  // If `merge` is true, update models here, instead of during update.
@@ -1341,11 +1357,11 @@
1341
1357
 
1342
1358
  /**
1343
1359
  * Get a specific relation.
1344
- * @param {string} key The relation key to look for.
1345
- * @return {Backbone.Relation} An instance of 'Backbone.Relation', if a relation was found for 'key', or null.
1360
+ * @param {string} attr The relation key to look for.
1361
+ * @return {Backbone.Relation} An instance of 'Backbone.Relation', if a relation was found for 'attr', or null.
1346
1362
  */
1347
- getRelation: function( key ) {
1348
- return this._relations[ key ];
1363
+ getRelation: function( attr ) {
1364
+ return this._relations[ attr ];
1349
1365
  },
1350
1366
 
1351
1367
  /**
@@ -1356,83 +1372,119 @@
1356
1372
  return _.values( this._relations );
1357
1373
  },
1358
1374
 
1375
+
1359
1376
  /**
1360
- * Retrieve related objects.
1361
- * @param {string} key The relation key to fetch models for.
1362
- * @param {Object} [options] Options for 'Backbone.Model.fetch' and 'Backbone.sync'.
1363
- * @param {Boolean} [refresh=false] Fetch existing models from the server as well (in order to update them).
1364
- * @return {jQuery.when[]} An array of request objects
1377
+ * Get a list of ids that will be fetched on a call to `getAsync`.
1378
+ * @param {string|Backbone.Relation} attr The relation key to fetch models for.
1379
+ * @param [refresh=false] Add ids for models that are already in the relation, refreshing them?
1380
+ * @return {Array} An array of ids that need to be fetched.
1365
1381
  */
1366
- fetchRelated: function( key, options, refresh ) {
1367
- // Set default `options` for fetch
1368
- options = _.extend( { update: true, remove: false }, options );
1369
-
1370
- var models,
1371
- setUrl,
1372
- requests = [],
1373
- rel = this.getRelation( key ),
1374
- idsToFetch = rel && ( ( rel.keyIds && rel.keyIds.slice( 0 ) ) || ( ( rel.keyId || rel.keyId === 0 ) ? [ rel.keyId ] : [] ) );
1382
+ getIdsToFetch: function( attr, refresh ) {
1383
+ var rel = attr instanceof Backbone.Relation ? attr : this.getRelation( attr ),
1384
+ ids = rel ? ( rel.keyIds && rel.keyIds.slice( 0 ) ) || ( ( rel.keyId || rel.keyId === 0 ) ? [ rel.keyId ] : [] ) : [];
1375
1385
 
1376
1386
  // On `refresh`, add the ids for current models in the relation to `idsToFetch`
1377
1387
  if ( refresh ) {
1378
- models = rel.related instanceof Backbone.Collection ? rel.related.models : [ rel.related ];
1388
+ var models = rel.related && ( rel.related.models || [ rel.related ] );
1379
1389
  _.each( models, function( model ) {
1380
1390
  if ( model.id || model.id === 0 ) {
1381
- idsToFetch.push( model.id );
1391
+ ids.push( model.id );
1382
1392
  }
1383
1393
  });
1384
1394
  }
1385
1395
 
1396
+ return ids;
1397
+ },
1398
+
1399
+ /**
1400
+ * Get related objects. Returns a single promise, which can either resolve immediately (if the related model[s])
1401
+ * are already present locally, or after fetching the contents of the requested attribute.
1402
+ * @param {string} attr The relation key to fetch models for.
1403
+ * @param {Object} [options] Options for 'Backbone.Model.fetch' and 'Backbone.sync'.
1404
+ * @param {Boolean} [options.refresh=false] Fetch existing models from the server as well (in order to update them).
1405
+ * @return {jQuery.Deferred} A jQuery promise object. When resolved, its `done` callback will be called with
1406
+ * contents of `attr`.
1407
+ */
1408
+ getAsync: function( attr, options ) {
1409
+ // Set default `options` for fetch
1410
+ options = _.extend( { add: true, remove: false, refresh: false }, options );
1411
+
1412
+ var dit = this,
1413
+ requests = [],
1414
+ rel = this.getRelation( attr ),
1415
+ idsToFetch = rel && this.getIdsToFetch( rel, options.refresh ),
1416
+ coll = rel.related instanceof Backbone.Collection ? rel.related : rel.relatedCollection;
1417
+
1386
1418
  if ( idsToFetch && idsToFetch.length ) {
1387
- // Find (or create) a model for each one that is to be fetched
1388
- var created = [];
1389
- models = _.map( idsToFetch, function( id ) {
1390
- var model = rel.relatedModel.findModel( id );
1391
-
1392
- if ( !model ) {
1393
- var attrs = {};
1394
- attrs[ rel.relatedModel.prototype.idAttribute ] = id;
1395
- model = rel.relatedModel.findOrCreate( attrs, options );
1396
- created.push( model );
1397
- }
1419
+ var models = [],
1420
+ createdModels = [],
1421
+ setUrl,
1422
+ createModels = function() {
1423
+ // Find (or create) a model for each one that is to be fetched
1424
+ models = _.map( idsToFetch, function( id ) {
1425
+ var model = rel.relatedModel.findModel( id );
1426
+
1427
+ if ( !model ) {
1428
+ var attrs = {};
1429
+ attrs[ rel.relatedModel.prototype.idAttribute ] = id;
1430
+ model = rel.relatedModel.findOrCreate( attrs, options );
1431
+ createdModels.push( model );
1432
+ }
1398
1433
 
1399
- return model;
1400
- }, this );
1434
+ return model;
1435
+ }, this );
1436
+ };
1401
1437
 
1402
1438
  // Try if the 'collection' can provide a url to fetch a set of models in one request.
1403
- if ( rel.related instanceof Backbone.Collection && _.isFunction( rel.related.url ) ) {
1404
- setUrl = rel.related.url( models );
1405
- }
1406
-
1407
- // An assumption is that when 'Backbone.Collection.url' is a function, it can handle building of set urls.
1439
+ // This assumes that when 'Backbone.Collection.url' is a function, it can handle building of set urls.
1408
1440
  // To make sure it can, test if the url we got by supplying a list of models to fetch is different from
1409
1441
  // the one supplied for the default fetch action (without args to 'url').
1410
- if ( setUrl && setUrl !== rel.related.url() ) {
1442
+ if ( coll instanceof Backbone.Collection && _.isFunction( coll.url ) ) {
1443
+ var defaultUrl = coll.url();
1444
+ setUrl = coll.url( idsToFetch );
1445
+
1446
+ if ( setUrl === defaultUrl ) {
1447
+ createModels();
1448
+ setUrl = coll.url( models );
1449
+
1450
+ if ( setUrl === defaultUrl ) {
1451
+ setUrl = null;
1452
+ }
1453
+ }
1454
+ }
1455
+
1456
+ if ( setUrl ) {
1457
+ // Do a single request to fetch all models
1411
1458
  var opts = _.defaults(
1412
1459
  {
1413
1460
  error: function() {
1414
- var args = arguments;
1415
- _.each( created, function( model ) {
1461
+ _.each( createdModels, function( model ) {
1416
1462
  model.trigger( 'destroy', model, model.collection, options );
1417
- options.error && options.error.apply( model, args );
1418
1463
  });
1464
+
1465
+ options.error && options.error.apply( models, arguments );
1419
1466
  },
1420
1467
  url: setUrl
1421
1468
  },
1422
1469
  options
1423
1470
  );
1424
1471
 
1425
- requests = [ rel.related.fetch( opts ) ];
1472
+ requests = [ coll.fetch( opts ) ];
1426
1473
  }
1427
1474
  else {
1475
+ // Make a request per model to fetch
1476
+ if ( !models.length ) {
1477
+ createModels();
1478
+ }
1479
+
1428
1480
  requests = _.map( models, function( model ) {
1429
1481
  var opts = _.defaults(
1430
1482
  {
1431
1483
  error: function() {
1432
- if ( _.contains( created, model ) ) {
1484
+ if ( _.contains( createdModels, model ) ) {
1433
1485
  model.trigger( 'destroy', model, model.collection, options );
1434
- options.error && options.error.apply( model, arguments );
1435
1486
  }
1487
+ options.error && options.error.apply( models, arguments );
1436
1488
  }
1437
1489
  },
1438
1490
  options
@@ -1442,47 +1494,20 @@
1442
1494
  }
1443
1495
  }
1444
1496
 
1445
- return requests;
1446
- },
1447
-
1448
- get: function( attr ) {
1449
- var originalResult = Backbone.Model.prototype.get.call( this, attr );
1450
-
1451
- // Use `originalResult` get if dotNotation not enabled or not required because no dot is in `attr`
1452
- if ( !this.dotNotation || attr.indexOf( '.' ) === -1 ) {
1453
- return originalResult;
1454
- }
1455
-
1456
- // Go through all splits and return the final result
1457
- var splits = attr.split( '.' );
1458
- var result = _.reduce( splits, function( model, split ) {
1459
- if ( _.isNull( model ) || _.isUndefined( model ) ) {
1460
- // Return undefined if the path cannot be expanded
1461
- return undefined;
1462
- }
1463
- else if ( model instanceof Backbone.Model ) {
1464
- return Backbone.Model.prototype.get.call( model, split );
1465
- }
1466
- else if ( model instanceof Backbone.Collection ) {
1467
- return Backbone.Collection.prototype.at.call( model, split )
1468
- }
1469
- else {
1470
- throw new Error( 'Attribute must be an instanceof Backbone.Model or Backbone.Collection. Is: ' + model + ', currentSplit: ' + split );
1497
+ return $.when.apply( null, requests ).then(
1498
+ function() {
1499
+ return Backbone.Model.prototype.get.call( dit, attr );
1471
1500
  }
1472
- }, this );
1473
-
1474
- if ( originalResult !== undefined && result !== undefined ) {
1475
- throw new Error( "Ambiguous result for '" + attr + "'. direct result: " + originalResult + ", dotNotation: " + result );
1476
- }
1477
-
1478
- return originalResult || result;
1501
+ );
1479
1502
  },
1480
1503
 
1481
1504
  set: function( key, value, options ) {
1482
1505
  Backbone.Relational.eventQueue.block();
1483
1506
 
1484
1507
  // Duplicate backbone's behavior to allow separate key/value parameters, instead of a single 'attributes' object
1485
- var attributes;
1508
+ var attributes,
1509
+ result;
1510
+
1486
1511
  if ( _.isObject( key ) || key == null ) {
1487
1512
  attributes = key;
1488
1513
  options = value;
@@ -1499,7 +1524,7 @@
1499
1524
  // Check if we're not setting a duplicate id before actually calling `set`.
1500
1525
  Backbone.Relational.store.checkId( this, newId );
1501
1526
 
1502
- var result = Backbone.Model.prototype.set.apply( this, arguments );
1527
+ result = Backbone.Model.prototype.set.apply( this, arguments );
1503
1528
 
1504
1529
  // Ideal place to set up relations, if this is the first time we're here for this model
1505
1530
  if ( !this._isInitialized && !this.isLocked() ) {
@@ -1612,6 +1637,13 @@
1612
1637
  delete json[ rel.key ];
1613
1638
  }
1614
1639
 
1640
+ // In case of `wait: true`, Backbone will simply push whatever's passed into `save` into attributes.
1641
+ // We'll want to get this information into the JSON, even if it doesn't conform to our normal
1642
+ // expectations of what's contained in it (no model/collection for a relation, etc).
1643
+ if ( value === null && options && options.wait ) {
1644
+ value = related;
1645
+ }
1646
+
1615
1647
  if ( includeInJSON ) {
1616
1648
  json[ rel.keyDestination ] = value;
1617
1649
  }
@@ -1724,6 +1756,7 @@
1724
1756
  }
1725
1757
  }
1726
1758
  }
1759
+
1727
1760
  return null;
1728
1761
  },
1729
1762
 
@@ -1783,7 +1816,7 @@
1783
1816
  * Find an instance of `this` type in 'Backbone.Relational.store'.
1784
1817
  * A new model is created if no matching model is found, `attributes` is an object, and `options.create` is true.
1785
1818
  * - If `attributes` is a string or a number, `findOrCreate` will query the `store` and return a model if found.
1786
- * - If `attributes` is an object and is found in the store, the model will be updated with `attributes` unless `options.update` is `false`.
1819
+ * - If `attributes` is an object and is found in the store, the model will be updated with `attributes` unless `options.merge` is `false`.
1787
1820
  * @param {Object|String|Number} attributes Either a model's id, or the attributes used to create or update a model.
1788
1821
  * @param {Object} [options]
1789
1822
  * @param {Boolean} [options.create=true]
@@ -1821,7 +1854,7 @@
1821
1854
  /**
1822
1855
  * Find an instance of `this` type in 'Backbone.Relational.store'.
1823
1856
  * - If `attributes` is a string or a number, `find` will query the `store` and return a model if found.
1824
- * - If `attributes` is an object and is found in the store, the model will be updated with `attributes` unless `options.update` is `false`.
1857
+ * - If `attributes` is an object and is found in the store, the model will be updated with `attributes` unless `options.merge` is `false`.
1825
1858
  * @param {Object|String|Number} attributes Either a model's id, or the attributes used to create or update a model.
1826
1859
  * @param {Object} [options]
1827
1860
  * @param {Boolean} [options.merge=true]
@@ -1891,7 +1924,7 @@
1891
1924
  Backbone.Collection.prototype.set = function( models, options ) {
1892
1925
  // Short-circuit if this Collection doesn't hold RelationalModels
1893
1926
  if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
1894
- return set.apply( this, arguments );
1927
+ return set.call( this, models, options );
1895
1928
  }
1896
1929
 
1897
1930
  if ( options && options.parse ) {
@@ -1900,41 +1933,42 @@
1900
1933
 
1901
1934
  var singular = !_.isArray( models ),
1902
1935
  newModels = [],
1903
- toAdd = [];
1936
+ toAdd = [],
1937
+ model = null;
1904
1938
 
1905
1939
  models = singular ? ( models ? [ models ] : [] ) : _.clone( models );
1906
1940
 
1907
1941
  //console.debug( 'calling add on coll=%o; model=%o, options=%o', this, models, options );
1908
- _.each( models, function( model ) {
1942
+ for ( var i = 0; i < models.length; i++ ) {
1943
+ model = models[i];
1909
1944
  if ( !( model instanceof Backbone.Model ) ) {
1910
1945
  model = Backbone.Collection.prototype._prepareModel.call( this, model, options );
1911
1946
  }
1912
-
1913
1947
  if ( model ) {
1914
1948
  toAdd.push( model );
1915
-
1916
1949
  if ( !( this.get( model ) || this.get( model.cid ) ) ) {
1917
1950
  newModels.push( model );
1918
1951
  }
1919
1952
  // If we arrive in `add` while performing a `set` (after a create, so the model gains an `id`),
1920
1953
  // we may get here before `_onModelEvent` has had the chance to update `_byId`.
1921
- else if ( model.id != null ) {
1954
+ else if ( model.id !== null && model.id !== undefined ) {
1922
1955
  this._byId[ model.id ] = model;
1923
1956
  }
1924
1957
  }
1925
- }, this );
1958
+ }
1926
1959
 
1927
1960
  // Add 'models' in a single batch, so the original add will only be called once (and thus 'sort', etc).
1928
1961
  // If `parse` was specified, the collection and contained models have been parsed now.
1929
1962
  toAdd = singular ? ( toAdd.length ? toAdd[ 0 ] : null ) : toAdd;
1930
- var result = set.call( this, toAdd, _.defaults( { parse: false }, options ) );
1963
+ var result = set.call( this, toAdd, _.defaults( { merge: false, parse: false }, options ) );
1931
1964
 
1932
- _.each( newModels, function( model ) {
1965
+ for ( i = 0; i < newModels.length; i++ ) {
1966
+ model = newModels[i];
1933
1967
  // Fire a `relational:add` event for any model in `newModels` that has actually been added to the collection.
1934
1968
  if ( this.get( model ) || this.get( model.cid ) ) {
1935
1969
  this.trigger( 'relational:add', model, this, options );
1936
1970
  }
1937
- }, this );
1971
+ }
1938
1972
 
1939
1973
  return result;
1940
1974
  };
@@ -1946,7 +1980,7 @@
1946
1980
  Backbone.Collection.prototype.remove = function( models, options ) {
1947
1981
  // Short-circuit if this Collection doesn't hold RelationalModels
1948
1982
  if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
1949
- return remove.apply( this, arguments );
1983
+ return remove.call( this, models, options );
1950
1984
  }
1951
1985
 
1952
1986
  var singular = !_.isArray( models ),
@@ -2034,7 +2068,7 @@
2034
2068
 
2035
2069
  // Override .extend() to automatically call .setup()
2036
2070
  Backbone.RelationalModel.extend = function( protoProps, classProps ) {
2037
- var child = Backbone.Model.extend.apply( this, arguments );
2071
+ var child = Backbone.Model.extend.call( this, protoProps, classProps );
2038
2072
 
2039
2073
  child.setup( this );
2040
2074
 
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backbone-relational-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Marsh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  description: Backbone-relational provides one-to-one, one-to-many and many-to-one
@@ -48,18 +48,19 @@ require_paths:
48
48
  - vendor
49
49
  required_ruby_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ! '>='
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ! '>='
56
+ - - '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
60
  rubyforge_project:
61
- rubygems_version: 2.2.0
61
+ rubygems_version: 2.2.2
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Backbone-relational packaged for Rails
65
65
  test_files: []
66
+ has_rdoc: