reactive-record 0.7.35 → 0.7.36

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: b2c3452956a7f5f694a3e57dbb0de12a11727854
4
- data.tar.gz: 5dfbe5870446dafaf6481ed27cd362d4e3e832b6
3
+ metadata.gz: 71c7a7abb7ea51cdb5f5139725724b0a1cd773fd
4
+ data.tar.gz: c1d222084866c7aa0f8b3f77d495825b504f3e35
5
5
  SHA512:
6
- metadata.gz: 1e91839b1180ae6bff126b71555bf7eaecde136b95f4d223f5edfa90e67e2508dcd73875ed3e3806da39f256d1f65aa798a29a51aaf8a8c259bd5efcf57b3776
7
- data.tar.gz: 5168e51dae8c78c0b049e0718b07bd22939fd75cf08b45b9b5de8a54013dc2846b65d5e6093cd7f99dd611784de6a539544bce3b7c54baeda6edec9fc8fceef6
6
+ metadata.gz: 0332dfa333ea3344e970d4b37c24a1ff9703823c5f53c645754de0b815a4254655f5da7dc15b3c0dbbd33b8adc522815395e6871d4eb61b826f9d16d5034125a
7
+ data.tar.gz: 1262dc1375cbbc0f423dde4d4e181bc69b2c44acad615944fd8833cd29efac2f6cb5d2338daa6f8b12b017cac75f4a93dd5b78cebdf0c032b5ec382c4e84177b
@@ -11,9 +11,10 @@ module ReactiveRecord
11
11
  params[:pending_fetches],
12
12
  acting_user
13
13
  ]
14
+ rescue Exception => e
15
+ render json: {error: e.message, backtrace: e.backtrace}, status: 500
14
16
  end
15
17
 
16
-
17
18
  def save
18
19
  render :json => ReactiveRecord::Base.save_records(
19
20
  (params[:models] || []).map(&:with_indifferent_access),
@@ -22,6 +23,8 @@ module ReactiveRecord
22
23
  params[:validate],
23
24
  true
24
25
  )
26
+ rescue Exception => e
27
+ render json: {error: e.message, backtrace: e.backtrace}, status: 500
25
28
  end
26
29
 
27
30
  def destroy
@@ -31,6 +34,8 @@ module ReactiveRecord
31
34
  params[:vector],
32
35
  acting_user
33
36
  )
37
+ rescue Exception => e
38
+ render json: {error: e.message, backtrace: e.backtrace}, status: 500
34
39
  end
35
40
 
36
41
  end
@@ -44,6 +44,7 @@ else
44
44
  require "reactive_record/server_data_cache"
45
45
  require "reactive_record/active_record/reactive_record/isomorphic_base"
46
46
  require "reactive_record/serializers"
47
+ require "reactive_record/pry"
47
48
 
48
49
  Opal.append_path File.expand_path('../', __FILE__).untaint
49
50
  Opal.append_path File.expand_path('../../vendor', __FILE__).untaint
@@ -267,11 +267,9 @@ module ReactiveRecord
267
267
  if !data_loading?
268
268
  React::State.set_state(self, attribute, value)
269
269
  elsif on_opal_client? and had_key and current_value.loaded? and current_value != value and args.count > 0 # this is to handle changes in already loaded server side methods
270
- puts "setting up delayed change for #{@ar_instance}.#{attribute} current: #{current_value} new: #{value}"
271
270
  React::State.set_state(self, attribute, value, true)
272
271
  end
273
272
  if empty_before != changed_attributes.empty?
274
- puts "setting up delayed change on record" unless on_opal_server? or data_loading?
275
273
  React::State.set_state(self, "!CHANGED!", !changed_attributes.empty?, true) unless on_opal_server? or data_loading?
276
274
  aggregate_owner.update_attribute(aggregate_attribute) if aggregate_owner
277
275
  end
@@ -324,7 +324,7 @@ module ReactiveRecord
324
324
  backing_records.each { |id, record| record.saved! }
325
325
 
326
326
  rescue Exception => e
327
- puts "Save Failed: #{e}"
327
+ log("Exception raised while saving - #{e}", :error)
328
328
  end
329
329
  end
330
330
  promise
@@ -372,156 +372,154 @@ module ReactiveRecord
372
372
 
373
373
  def self.save_records(models, associations, acting_user, validate, save)
374
374
 
375
- reactive_records = {}
376
- vectors = {}
377
- new_models = []
378
- saved_models = []
379
- dont_save_list = []
380
-
381
- models.each do |model_to_save|
382
- attributes = model_to_save[:attributes]
383
- model = Object.const_get(model_to_save[:model])
384
- id = attributes.delete(model.primary_key) if model.respond_to? :primary_key # if we are saving existing model primary key value will be present
385
- vector = model_to_save[:vector]
386
- vector = [vector[0].constantize] + vector[1..-1].collect do |method|
387
- if method.is_a?(Array) and method.first == "find_by_id"
388
- ["find", method.last]
389
- else
390
- method
391
- end
392
- end
393
- reactive_records[model_to_save[:id]] = vectors[vector] = record = find_record(model, id, vector, save)
394
- if record and record.respond_to?(:id) and record.id
395
- # we have an already exising activerecord model
396
- keys = record.attributes.keys
397
- attributes.each do |key, value|
398
- if keys.include? key
399
- record[key] = value
400
- elsif !value.nil? and aggregation = record.class.reflect_on_aggregation(key.to_sym) and !(aggregation.klass < ActiveRecord::Base)
401
- aggregation.mapping.each_with_index do |pair, i|
402
- record[pair.first] = value[i]
375
+ ReactiveRecord::Pry.rescue do
376
+ begin
377
+
378
+ reactive_records = {}
379
+ vectors = {}
380
+ new_models = []
381
+ saved_models = []
382
+ dont_save_list = []
383
+
384
+ models.each do |model_to_save|
385
+ attributes = model_to_save[:attributes]
386
+ model = Object.const_get(model_to_save[:model])
387
+ id = attributes.delete(model.primary_key) if model.respond_to? :primary_key # if we are saving existing model primary key value will be present
388
+ vector = model_to_save[:vector]
389
+ vector = [vector[0].constantize] + vector[1..-1].collect do |method|
390
+ if method.is_a?(Array) and method.first == "find_by_id"
391
+ ["find", method.last]
392
+ else
393
+ method
403
394
  end
404
- elsif record.respond_to? "#{key}="
405
- record.send("#{key}=",value)
406
- else
407
- # TODO once reading schema.rb on client is implemented throw an error here
408
395
  end
409
- end
410
- elsif record
411
- # either the model is new, or its not even an active record model
412
- dont_save_list << record unless save
413
- keys = record.attributes.keys
414
- attributes.each do |key, value|
415
- if keys.include? key
416
- record[key] = value
417
- elsif !value.nil? and aggregation = record.class.reflect_on_aggregation(key) and !(aggregation.klass < ActiveRecord::Base)
418
- aggregation.mapping.each_with_index do |pair, i|
419
- record[pair.first] = value[i]
396
+ reactive_records[model_to_save[:id]] = vectors[vector] = record = find_record(model, id, vector, save)
397
+ if record and record.respond_to?(:id) and record.id
398
+ # we have an already exising activerecord model
399
+ keys = record.attributes.keys
400
+ attributes.each do |key, value|
401
+ if keys.include? key
402
+ record[key] = value
403
+ elsif !value.nil? and aggregation = record.class.reflect_on_aggregation(key.to_sym) and !(aggregation.klass < ActiveRecord::Base)
404
+ aggregation.mapping.each_with_index do |pair, i|
405
+ record[pair.first] = value[i]
406
+ end
407
+ elsif record.respond_to? "#{key}="
408
+ record.send("#{key}=",value)
409
+ else
410
+ # TODO once reading schema.rb on client is implemented throw an error here
411
+ end
420
412
  end
421
- elsif key.to_s != "id" and record.respond_to?("#{key}=") # server side methods can get included and we won't be able to write them...
422
- # for example if you have a server side method foo, that you "get" on a new record, then later that value will get sent to the server
423
- # we should track better these server side methods so this does not happen
424
- record.send("#{key}=",value)
413
+ elsif record
414
+ # either the model is new, or its not even an active record model
415
+ dont_save_list << record unless save
416
+ keys = record.attributes.keys
417
+ attributes.each do |key, value|
418
+ if keys.include? key
419
+ record[key] = value
420
+ elsif !value.nil? and aggregation = record.class.reflect_on_aggregation(key) and !(aggregation.klass < ActiveRecord::Base)
421
+ aggregation.mapping.each_with_index do |pair, i|
422
+ record[pair.first] = value[i]
423
+ end
424
+ elsif key.to_s != "id" and record.respond_to?("#{key}=") # server side methods can get included and we won't be able to write them...
425
+ # for example if you have a server side method foo, that you "get" on a new record, then later that value will get sent to the server
426
+ # we should track better these server side methods so this does not happen
427
+ record.send("#{key}=",value)
428
+ end
429
+ end
430
+ new_models << record
425
431
  end
426
432
  end
427
- new_models << record
428
- end
429
- end
430
433
 
431
- puts "!!!!!!!!!!!!!!attributes updated"
432
- ActiveRecord::Base.transaction do
433
- associations.each do |association|
434
- parent = reactive_records[association[:parent_id]]
435
- next unless parent
436
- #parent.instance_variable_set("@reactive_record_#{association[:attribute]}_changed", true) remove this????
437
- if parent.class.reflect_on_aggregation(association[:attribute].to_sym)
438
- puts ">>>>>>AGGREGATE>>>> #{parent.class.name}.send('#{association[:attribute]}=', #{reactive_records[association[:child_id]]})"
439
- aggregate = reactive_records[association[:child_id]]
440
- dont_save_list << aggregate
441
- current_attributes = parent.send(association[:attribute]).attributes
442
- puts "current parent attributes = #{current_attributes}"
443
- new_attributes = aggregate.attributes
444
- puts "current child attributes = #{new_attributes}"
445
- merged_attributes = current_attributes.merge(new_attributes) { |k, current_attr, new_attr| aggregate.send("#{k}_changed?") ? new_attr : current_attr}
446
- puts "merged attributes = #{merged_attributes}"
447
- aggregate.assign_attributes(merged_attributes)
448
- puts "aggregate attributes after merge = #{aggregate.attributes}"
449
- parent.send("#{association[:attribute]}=", aggregate)
450
- puts "updated is frozen? #{aggregate.frozen?}, parent attributes = #{parent.send(association[:attribute]).attributes}"
451
- elsif parent.class.reflect_on_association(association[:attribute].to_sym).nil?
452
- raise "Missing association :#{association[:attribute]} for #{parent.class.name}. Was association defined on opal side only?"
453
- elsif parent.class.reflect_on_association(association[:attribute].to_sym).collection?
454
- puts ">>>>>>>>>> #{parent.class.name}.send('#{association[:attribute]}') << #{reactive_records[association[:child_id]]})"
455
- dont_save_list.delete(parent)
456
- if false and parent.new?
457
- parent.send("#{association[:attribute]}") << reactive_records[association[:child_id]] if parent.new?
458
- puts "updated"
459
- else
460
- puts "skipped"
461
- end
462
- else
463
- puts ">>>>ASSOCIATION>>>> #{parent.class.name}.send('#{association[:attribute]}=', #{reactive_records[association[:child_id]]})"
464
- parent.send("#{association[:attribute]}=", reactive_records[association[:child_id]])
465
- dont_save_list.delete(parent)
466
- puts "updated"
467
- end
468
- end if associations
469
-
470
- puts "!!!!!!!!!!!!associations updated"
471
-
472
- #if true or save
473
-
474
- # ActiveRecord::Base.transaction do
475
-
476
- has_errors = false
477
-
478
- puts "ready to start saving... dont_save_list = #{dont_save_list}"
479
-
480
- saved_models = reactive_records.collect do |reactive_record_id, model|
481
- puts "saving rr_id: #{reactive_record_id} model.object_id: #{model.object_id} frozen? <#{model.frozen?}>"
482
- if model and (model.frozen? or dont_save_list.include?(model) or model.changed.include?(model.class.primary_key))
483
- # the above check for changed including the private key happens if you have an aggregate that includes its own id
484
- puts "validating frozen model #{model.class.name} #{model} (reactive_record_id = #{reactive_record_id})"
485
- valid = model.valid?
486
- puts "has_errors before = #{has_errors}, validate= #{validate}, !valid= #{!valid} (validate and !valid) #{validate and !valid}"
487
- has_errors ||= (validate and !valid)
488
- puts "validation complete errors = <#{!valid}>, #{model.errors.messages} has_errors #{has_errors}"
489
- [reactive_record_id, model.class.name, model.attributes, (valid ? nil : model.errors.messages)]
490
- elsif model and (!model.id or model.changed?)
491
- puts "saving #{model.class.name} #{model} (reactive_record_id = #{reactive_record_id})"
492
- saved = model.check_permission_with_acting_user(acting_user, new_models.include?(model) ? :create_permitted? : :update_permitted?).save(validate: validate)
493
- has_errors ||= !saved
494
- messages = model.errors.messages if (validate and !saved) or (!validate and !model.valid?)
495
- puts "saved complete errors = <#{!saved}>, #{messages} has_errors #{has_errors}"
496
- [reactive_record_id, model.class.name, model.attributes, messages]
497
- end
498
- end.compact
434
+ #puts "!!!!!!!!!!!!!!attributes updated"
435
+ ActiveRecord::Base.transaction do
436
+ associations.each do |association|
437
+ parent = reactive_records[association[:parent_id]]
438
+ next unless parent
439
+ #parent.instance_variable_set("@reactive_record_#{association[:attribute]}_changed", true) remove this????
440
+ if parent.class.reflect_on_aggregation(association[:attribute].to_sym)
441
+ #puts ">>>>>>AGGREGATE>>>> #{parent.class.name}.send('#{association[:attribute]}=', #{reactive_records[association[:child_id]]})"
442
+ aggregate = reactive_records[association[:child_id]]
443
+ dont_save_list << aggregate
444
+ current_attributes = parent.send(association[:attribute]).attributes
445
+ #puts "current parent attributes = #{current_attributes}"
446
+ new_attributes = aggregate.attributes
447
+ #puts "current child attributes = #{new_attributes}"
448
+ merged_attributes = current_attributes.merge(new_attributes) { |k, current_attr, new_attr| aggregate.send("#{k}_changed?") ? new_attr : current_attr}
449
+ #puts "merged attributes = #{merged_attributes}"
450
+ aggregate.assign_attributes(merged_attributes)
451
+ #puts "aggregate attributes after merge = #{aggregate.attributes}"
452
+ parent.send("#{association[:attribute]}=", aggregate)
453
+ #puts "updated is frozen? #{aggregate.frozen?}, parent attributes = #{parent.send(association[:attribute]).attributes}"
454
+ elsif parent.class.reflect_on_association(association[:attribute].to_sym).nil?
455
+ raise "Missing association :#{association[:attribute]} for #{parent.class.name}. Was association defined on opal side only?"
456
+ elsif parent.class.reflect_on_association(association[:attribute].to_sym).collection?
457
+ #puts ">>>>>>>>>> #{parent.class.name}.send('#{association[:attribute]}') << #{reactive_records[association[:child_id]]})"
458
+ dont_save_list.delete(parent)
459
+ if false and parent.new?
460
+ parent.send("#{association[:attribute]}") << reactive_records[association[:child_id]] if parent.new?
461
+ #puts "updated"
462
+ else
463
+ #puts "skipped"
464
+ end
465
+ else
466
+ #puts ">>>>ASSOCIATION>>>> #{parent.class.name}.send('#{association[:attribute]}=', #{reactive_records[association[:child_id]]})"
467
+ parent.send("#{association[:attribute]}=", reactive_records[association[:child_id]])
468
+ dont_save_list.delete(parent)
469
+ #puts "updated"
470
+ end
471
+ end if associations
472
+
473
+ #puts "!!!!!!!!!!!!associations updated"
474
+
475
+ has_errors = false
476
+
477
+ #puts "ready to start saving... dont_save_list = #{dont_save_list}"
478
+
479
+ saved_models = reactive_records.collect do |reactive_record_id, model|
480
+ #puts "saving rr_id: #{reactive_record_id} model.object_id: #{model.object_id} frozen? <#{model.frozen?}>"
481
+ if model and (model.frozen? or dont_save_list.include?(model) or model.changed.include?(model.class.primary_key))
482
+ # the above check for changed including the private key happens if you have an aggregate that includes its own id
483
+ #puts "validating frozen model #{model.class.name} #{model} (reactive_record_id = #{reactive_record_id})"
484
+ valid = model.valid?
485
+ #puts "has_errors before = #{has_errors}, validate= #{validate}, !valid= #{!valid} (validate and !valid) #{validate and !valid}"
486
+ has_errors ||= (validate and !valid)
487
+ #puts "validation complete errors = <#{!valid}>, #{model.errors.messages} has_errors #{has_errors}"
488
+ [reactive_record_id, model.class.name, model.attributes, (valid ? nil : model.errors.messages)]
489
+ elsif model and (!model.id or model.changed?)
490
+ #puts "saving #{model.class.name} #{model} (reactive_record_id = #{reactive_record_id})"
491
+ saved = model.check_permission_with_acting_user(acting_user, new_models.include?(model) ? :create_permitted? : :update_permitted?).save(validate: validate)
492
+ has_errors ||= !saved
493
+ messages = model.errors.messages if (validate and !saved) or (!validate and !model.valid?)
494
+ #puts "saved complete errors = <#{!saved}>, #{messages} has_errors #{has_errors}"
495
+ [reactive_record_id, model.class.name, model.attributes, messages]
496
+ end
497
+ end.compact
499
498
 
500
- raise "Could not save all models" if has_errors
499
+ raise "Could not save all models" if has_errors
501
500
 
502
- # end
503
- if save
501
+ if save
504
502
 
505
- {success: true, saved_models: saved_models }
503
+ {success: true, saved_models: saved_models }
506
504
 
507
- else
505
+ else
508
506
 
509
- vectors.each { |vector, model| model.reload unless model.nil? or model.new_record? or model.frozen? }
510
- vectors
507
+ vectors.each { |vector, model| model.reload unless model.nil? or model.new_record? or model.frozen? }
508
+ vectors
511
509
 
512
- end
510
+ end
513
511
 
514
- end
512
+ end
515
513
 
516
- rescue Exception => e
517
- puts "exception #{e}"
518
- puts e.backtrace.join("\n")
519
- if save
520
- {success: false, saved_models: saved_models, message: e.message}
521
- else
522
- {}
514
+ rescue Exception => e
515
+ ReactiveRecord::Pry.rescued(e)
516
+ if save
517
+ {success: false, saved_models: saved_models, message: e}
518
+ else
519
+ {}
520
+ end
521
+ end
523
522
  end
524
-
525
523
  end
526
524
 
527
525
  end
@@ -569,19 +567,26 @@ module ReactiveRecord
569
567
  else
570
568
 
571
569
  def self.destroy_record(model, id, vector, acting_user)
572
- model = Object.const_get(model)
573
- record = if id
574
- model.find(id)
575
- else
576
- ServerDataCache.new(acting_user, {})[*vector]
577
- end
578
- record.check_permission_with_acting_user(acting_user, :destroy_permitted?).destroy
579
- {success: true, attributes: {}}
580
570
 
581
- rescue Exception => e
582
- {success: false, record: record, message: e.message}
583
- end
571
+ ReactiveRecord::Pry.rescue do
572
+ begin
573
+ model = Object.const_get(model)
574
+ record = if id
575
+ model.find(id)
576
+ else
577
+ ServerDataCache.new(acting_user, {})[*vector]
578
+ end
579
+
584
580
 
581
+ record.check_permission_with_acting_user(acting_user, :destroy_permitted?).destroy
582
+ {success: true, attributes: {}}
583
+
584
+ rescue Exception => e
585
+ ReactiveRecord::Pry.rescued(e)
586
+ {success: false, record: record, message: e}
587
+ end
588
+ end
589
+ end
585
590
  end
586
591
  end
587
592
 
@@ -116,9 +116,7 @@ module ReactiveRecord
116
116
  end
117
117
 
118
118
  def loaded_at(loaded_at)
119
- puts "loaded_at started"
120
119
  React::State.set_state(self, :loaded_at, loaded_at)
121
- puts "loaded_at done"
122
120
  @is_loading = false
123
121
  end
124
122
 
@@ -1,55 +1,63 @@
1
+ module ReactiveRecord
2
+ class AccessViolation < StandardError
3
+ def message
4
+ "ReactiveRecord::AccessViolation: #{super}"
5
+ end
6
+ end
7
+ end
8
+
1
9
  class ActiveRecord::Base
2
-
10
+
3
11
  attr_accessor :acting_user
4
-
12
+
5
13
  def create_permitted?
6
14
  true
7
15
  end
8
-
16
+
9
17
  def update_permitted?
10
18
  true
11
19
  end
12
-
20
+
13
21
  def destroy_permitted?
14
22
  true
15
23
  end
16
-
17
- def view_permitted?(attribute)
24
+
25
+ def view_permitted?(attribute)
18
26
  true
19
27
  end
20
-
28
+
21
29
  def only_changed?(*attributes)
22
30
  (self.attributes.keys + self.class.reactive_record_association_keys).each do |key|
23
31
  return false if self.send("#{key}_changed?") and !attributes.include? key
24
32
  end
25
33
  true
26
34
  end
27
-
35
+
28
36
  def none_changed?(*attributes)
29
37
  attributes.each do |key|
30
38
  return false if self.send("#{key}_changed?")
31
39
  end
32
40
  true
33
41
  end
34
-
42
+
35
43
  def any_changed?(*attributes)
36
44
  attributes.each do |key|
37
45
  return true if self.send("#{key}_changed?")
38
46
  end
39
47
  false
40
- end
41
-
48
+ end
49
+
42
50
  def all_changed?(*attributes)
43
51
  attributes.each do |key|
44
52
  return false unless self.send("#{key}_changed?")
45
53
  end
46
54
  true
47
55
  end
48
-
56
+
49
57
  class << self
50
-
58
+
51
59
  attr_reader :reactive_record_association_keys
52
-
60
+
53
61
  [:has_many, :belongs_to, :composed_of].each do |macro|
54
62
  define_method "#{macro}_with_reactive_record_add_changed_method".to_sym do |attr_name, *args, &block|
55
63
  define_method "#{attr_name}_changed?".to_sym do
@@ -60,19 +68,19 @@ class ActiveRecord::Base
60
68
  end
61
69
  alias_method_chain macro, :reactive_record_add_changed_method
62
70
  end
63
-
71
+
64
72
  def belongs_to_with_reactive_record_add_is_method(attr_name, scope = nil, options = {})
65
73
  define_method "#{attr_name}_is?".to_sym do |model|
66
74
  send(options[:foreign_key] || "#{attr_name}_id") == model.id
67
75
  end
68
76
  belongs_to_without_reactive_record_add_is_method(attr_name, scope, options)
69
77
  end
70
-
78
+
71
79
  alias_method_chain :belongs_to, :reactive_record_add_is_method
72
-
80
+
73
81
  end
74
-
75
-
82
+
83
+
76
84
  def check_permission_with_acting_user(user, permission, *args)
77
85
  old = acting_user
78
86
  self.acting_user = user
@@ -80,15 +88,15 @@ class ActiveRecord::Base
80
88
  self.acting_user = old
81
89
  self
82
90
  else
83
- raise "ReactiveRecord Access Violation: #{permission}(#{args}) returned false"
91
+ raise ReactiveRecord::AccessViolation, "for #{permission}(#{args})"
84
92
  end
85
93
  end
86
-
94
+
87
95
  end
88
96
 
89
97
  class ActionController::Base
90
-
98
+
91
99
  def acting_user
92
100
  end
93
-
94
- end
101
+
102
+ end
@@ -0,0 +1,19 @@
1
+ module ReactiveRecord
2
+
3
+ module Pry
4
+
5
+ def self.rescue(&block)
6
+ if defined? PryRescue
7
+ ::Pry::rescue &block
8
+ else
9
+ block.call
10
+ end
11
+ end
12
+
13
+ def self.rescued(e)
14
+ ::Pry::rescued(e) if defined?(PryRescue) && !e.is_a?(ReactiveRecord::AccessViolation)
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -186,13 +186,16 @@ module ReactiveRecord
186
186
  elsif aggregation = cache_item.aggregation?(method)
187
187
  cache_item.build_new_cache_item(aggregation.mapping.collect { |attribute, accessor| cache_item.value[attribute] }, method, method)
188
188
  else
189
- begin
190
- cache_item.build_new_cache_item(cache_item.value.send(*method), method, method)
191
- rescue Exception => e
192
- if cache_item.value and cache_item.value != []
193
- raise "ReactiveRecord exception caught when applying #{method} to db object #{cache_item.value}: #{e}"
194
- else
195
- representative
189
+ ReactiveRecord::Pry::rescue do
190
+ begin
191
+ cache_item.build_new_cache_item(cache_item.value.send(*method), method, method)
192
+ rescue Exception => e
193
+ if cache_item.value and cache_item.value != []
194
+ ReactiveRecord::Pry::rescued(e)
195
+ raise e, "ReactiveRecord exception caught when applying #{method} to db object #{cache_item.value}: #{e}", e.backtrace
196
+ else
197
+ representative
198
+ end
196
199
  end
197
200
  end
198
201
  end
@@ -1,3 +1,3 @@
1
1
  module ReactiveRecord
2
- VERSION = "0.7.35"
2
+ VERSION = "0.7.36"
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.35
4
+ version: 0.7.36
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-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -164,6 +164,7 @@ files:
164
164
  - lib/reactive_record/engine.rb
165
165
  - lib/reactive_record/interval.rb
166
166
  - lib/reactive_record/permissions.rb
167
+ - lib/reactive_record/pry.rb
167
168
  - lib/reactive_record/serializers.rb
168
169
  - lib/reactive_record/server_data_cache.rb
169
170
  - lib/reactive_record/version.rb