reactive-record 0.7.27 → 0.7.28

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: d768497702030401fd48ec8d9149f4c74e20c725
4
- data.tar.gz: 4fbf024a9ade1663b8b2b0106f982d39b5642c92
3
+ metadata.gz: 4a5269da6b54feb09d691d5852e4b236b689d662
4
+ data.tar.gz: e6b947731add8eadc82e10b788d3880847665fb4
5
5
  SHA512:
6
- metadata.gz: cdd59f7cc5d7704559c48099fb91c81b6ce124ad8817be2bf8a8b755d272dab3a8f2514cb3e48ddcf99dcd9ccd26b7f097fe56595ea94912f99cc5f6b65292bb
7
- data.tar.gz: e09150e494aadd60d997b79473bd9cc9377027b4ea585f5ed243c34cf69629dc22be59e53c0aa39fc5772baea063c74b66c47d79fe4660efb3b57e00d6dfc16e
6
+ metadata.gz: 89102826cb196baffc99df77f910b6b5e620556c1ab7c2134fab12c46e05a0ee9b1ae564faddc51511f8674b136b1ad7b64235c709be7bda44b6ff41943aaf28
7
+ data.tar.gz: 4d8f4b1cf33dbb4391b2e094732cfdec9f329e88fff3eae8b45bfdac2c9a1e0212872c05de9d54fbfa1dcb459b56af1fc1b692820decc52a14eb957bfff377a0
@@ -35,6 +35,7 @@ module ReactiveRecord
35
35
  attr_accessor :destroyed
36
36
  attr_accessor :updated_during
37
37
  attr_accessor :synced_attributes
38
+ attr_accessor :virgin
38
39
 
39
40
  # While data is being loaded from the server certain internal behaviors need to change
40
41
  # for example records all record changes are synced as they happen.
@@ -86,7 +87,6 @@ module ReactiveRecord
86
87
  # and set the primary if we have one
87
88
  record.sync_attribute(model.primary_key, id) if id
88
89
  end
89
-
90
90
  # finally initialize and return the ar_instance
91
91
  record.ar_instance ||= infer_type_from_hash(model, record.attributes).new(record)
92
92
  end
@@ -214,6 +214,7 @@ module ReactiveRecord
214
214
  end
215
215
 
216
216
  aggregate_record = attributes[attribute].backing_record
217
+ aggregate_record.virgin = false
217
218
 
218
219
  if value
219
220
  value_attributes = value.backing_record.attributes
@@ -475,7 +475,8 @@ module ReactiveRecord
475
475
 
476
476
  saved_models = reactive_records.collect do |reactive_record_id, model|
477
477
  puts "saving rr_id: #{reactive_record_id} model.object_id: #{model.object_id} frozen? <#{model.frozen?}>"
478
- if model and (model.frozen? or dont_save_list.include?(model))
478
+ if model and (model.frozen? or dont_save_list.include?(model) or model.changed.include?(model.class.primary_key))
479
+ # the above check for changed including the private key happens if you have an aggregate that includes its own id
479
480
  puts "validating frozen model #{model.class.name} #{model} (reactive_record_id = #{reactive_record_id})"
480
481
  valid = model.valid?
481
482
  puts "has_errors before = #{has_errors}, validate= #{validate}, !valid= #{!valid} (validate and !valid) #{validate and !valid}"
@@ -187,9 +187,11 @@ module ReactiveRecord
187
187
  self
188
188
  end
189
189
  rescue Exception => e
190
- binding.pry if cache_item.value and cache_item.value != []
191
- raise "ReactiveRecord exception caught when applying #{method} to db objects #{e}" if cache_item.value and cache_item.value != []
192
- representative
190
+ if cache_item.value and cache_item.value != []
191
+ raise "ReactiveRecord exception caught when applying #{method} to db object #{cache_item.value}: #{e}"
192
+ else
193
+ representative
194
+ end
193
195
  end
194
196
  else
195
197
  representative
@@ -314,8 +316,8 @@ module ReactiveRecord
314
316
  target.send "#{method}=", aggregation.deserialize(value.first)
315
317
  elsif value.is_a? Array
316
318
  target.send "#{method}=", value.first unless method == "id" # we handle ids first so things sync nicely
317
- elsif value.is_a? Hash and value[:id] and value[:id].first #and
318
- association = target.class.reflect_on_association(method)
319
+ elsif value.is_a? Hash and value[:id] and value[:id].first and association = target.class.reflect_on_association(method)
320
+ # not sure if its necessary to check the id above... is it possible to for the method to be an association but not have an id?
319
321
  new_target = association.klass.find(value[:id].first)
320
322
  target.send "#{method}=", new_target
321
323
  elsif !(target.class < ActiveRecord::Base)
@@ -1,3 +1,3 @@
1
1
  module ReactiveRecord
2
- VERSION = "0.7.27"
2
+ VERSION = "0.7.28"
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.27
4
+ version: 0.7.28
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-16 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails