reactive-record 0.7.29 → 0.7.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9ffa135c5fea49dd89fd26b3180299ff96fa2be
4
- data.tar.gz: 759eb5f92565c62ce05f23c5be19955f914142f0
3
+ metadata.gz: b6bb1cc3265c0141b9757c88ceb4e7fcbf958d00
4
+ data.tar.gz: 6c55106b465a686d47393255977e7044d1841ce6
5
5
  SHA512:
6
- metadata.gz: dd724c0c0471ceea9c92d9c9a16f1c19f39a47ca40fe367f32c6eb504ef08141f45d69f48b52cfa9a0e99634e920cbddb87a776e75621870a7b9bcc7d4284a9c
7
- data.tar.gz: 1a8b1bedcdafa10a6bfae116a1ace66e7f8eb7149dfc59e903b32753490cb4cd2814670404f372e60738a3a4b9b943baf767b21e02fe055322264c9ff2f990fd
6
+ metadata.gz: 1721fdfe1bc81b417c9c722efa2b1ec89a8726cedf474d5811a2cd3bdfba30506343d3b33c54115a575ca8d53f3596ffbcaf3f702993fadee41f86e424fa8852
7
+ data.tar.gz: 42145c75a12201d4c8d699019dc16f12a86a4f6c0d55e16457c82f3cf6033d98091b5c8fd4496f94feaa888502fd3bccecec62c0fa00c78e5ce688f7a079d09c
@@ -263,11 +263,15 @@ module ReactiveRecord
263
263
  record.attributes.each do |attribute, value|
264
264
  if association = record.model.reflect_on_association(attribute)
265
265
  if association.collection?
266
- value.each { |assoc| add_new_association.call record, attribute, assoc.backing_record }
267
- elsif !value.nil?
268
- add_new_association.call record, attribute, value.backing_record
269
- else
270
- output_attributes[attribute] = nil
266
+ value.each do |assoc|
267
+ add_new_association.call(record, attribute, assoc.backing_record) if assoc.changed?(association.inverse_of) or assoc.new?
268
+ end
269
+ elsif record.new? || record.changed?(attribute) || (record == record_being_saved && force)
270
+ if value.nil?
271
+ output_attributes[attribute] = nil
272
+ else
273
+ add_new_association.call record, attribute, value.backing_record
274
+ end
271
275
  end
272
276
  elsif aggregation = record.model.reflect_on_aggregation(attribute) and (aggregation.klass < ActiveRecord::Base)
273
277
  add_new_association.call record, attribute, value.backing_record unless value.nil?
@@ -357,7 +361,7 @@ module ReactiveRecord
357
361
  object.send(method)
358
362
  end
359
363
  end
360
- if id and (found.nil? or !(found.class <= model) or found.id != id)
364
+ if id and (found.nil? or !(found.class <= model) or found.id.to_s != id.to_s)
361
365
  raise "Inconsistent data sent to server - #{model.name}.find(#{id}) != [#{vector}]"
362
366
  end
363
367
  found
@@ -1,3 +1,3 @@
1
1
  module ReactiveRecord
2
- VERSION = "0.7.29"
2
+ VERSION = "0.7.30"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.29
4
+ version: 0.7.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch VanDuyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails