backbone-associations-rails 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,11 +16,11 @@ Add this line to your application's Gemfile:
16
16
 
17
17
  Then require it in your javascript manifest file (```application.js``` by default)
18
18
 
19
- //= reuqire backbone-associations
19
+ //= require backbone-associations
20
20
 
21
21
  ## Versioning
22
22
 
23
23
  ```backbone-associations-rails``` will track the version of ```backbone-associations```.
24
24
 
25
25
  ## Issues
26
- For issues with ```backbone-associations```, please file an issue over at their [issue tracker](https://github.com/dhruvaray/backbone-associations/issues).
26
+ For issues with ```backbone-associations```, please file an issue over at their [issue tracker](https://github.com/dhruvaray/backbone-associations/issues). Otherwise, please file an issue here.
@@ -1,7 +1,7 @@
1
1
  module Backbone
2
2
  module Associations
3
3
  module Rails
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  //
2
- // Backbone-associations.js 0.4.1
2
+ // Backbone-associations.js 0.4.2
3
3
  //
4
4
  // (c) 2013 Dhruva Ray, Jaynti Kanani, Persistent Systems Ltd.
5
5
  // Backbone-associations may be freely distributed under the MIT license.
@@ -135,14 +135,9 @@
135
135
  data = val;
136
136
  attributes[relationKey] = data;
137
137
  } else {
138
- if (!this.attributes[relationKey]) {
139
- data = collectionType ? new collectionType() : this._createCollection(relatedModel);
140
- data.add(val, relationOptions);
141
- attributes[relationKey] = data;
142
- } else {
143
- this.attributes[relationKey].reset(val, relationOptions);
144
- delete attributes[relationKey];
145
- }
138
+ data = collectionType ? new collectionType() : this._createCollection(relatedModel);
139
+ data.add(val, relationOptions);
140
+ attributes[relationKey] = data;
146
141
  }
147
142
 
148
143
  } else if (relation.type === Backbone.One && relatedModel) {
@@ -185,10 +180,14 @@
185
180
  initialTokens = _.initial(pathTokens), colModel;
186
181
 
187
182
  colModel = relationValue.find(function (model) {
188
- var changedModel = model.get(pathTokens);
189
- return eventObject === (changedModel instanceof AssociatedModel
190
- || changedModel instanceof BackboneCollection)
191
- ? changedModel : (model.get(initialTokens) || model);
183
+ if (eventObject === model) return true;
184
+ if (model) {
185
+ var changedModel = model.get(initialTokens);
186
+ if ((changedModel instanceof AssociatedModel || changedModel instanceof BackboneCollection) && eventObject === changedModel) return true;
187
+ changedModel = model.get(pathTokens);
188
+ return ((changedModel instanceof AssociatedModel || changedModel instanceof BackboneCollection) && eventObject === changedModel);
189
+ }
190
+ return false;
192
191
  });
193
192
  colModel && (indexEventObject = relationValue.indexOf(colModel));
194
193
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backbone-associations-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-07 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Backbone-associations provides a way of specifying 1:1 and 1:N relationships
15
15
  between Backbone models. Additionally, parent model instances (and objects extended