reactive-record 0.7.12 → 0.7.13

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: 20ba896842b898324934f9ede8523629f9ea8ca8
4
- data.tar.gz: 1ca9086a7a22e06608995599e5e66145b939c43f
3
+ metadata.gz: 50274de5e97355af971444c44fc6e11c7d6cc5bf
4
+ data.tar.gz: 6826664275c50d1c5c9ac06ff2e9ae624b0f8be5
5
5
  SHA512:
6
- metadata.gz: b36afcbffd5e424ccb005cf321d3f830df588c259e198f3b7dc465b62476d7687761c4486f54e6ddc43b2bdb0b7fb51d8835c0b2c90d5c2609f178782abf1341
7
- data.tar.gz: 77b1454fb5434af9d1b69ee4763eb1ed5e25b302117f889a0e9d3986c8c525fc50e711138bb5880a2bb6e5cd4ca40e8a3f9b5937b712b3b44e14ecd5a0139729
6
+ metadata.gz: 24ca2f3773a7c226c3132f1aaff9d868b3bf91705b202b14681f2f157da5a66654542151419067f1c97c0a8943a8adbad43b9ecfdb73d678dbfe90198e49c181
7
+ data.tar.gz: 59a9ca009c337aa4ec5e51252a317b3857593d5359759df24bafec1c1d92347497c593a440d0c6b6aa58370021c60a977d0b63357a05dcb9d0641baa51e79aa1
@@ -110,7 +110,11 @@ module ActiveRecord
110
110
  klass = ReactiveRecord::Base.infer_type_from_hash(self, param)
111
111
  klass == self or klass < self
112
112
  else
113
- target = find(param[primary_key])
113
+ if param[primary_key]
114
+ target = find(param[primary_key])
115
+ else
116
+ target = new
117
+ end
114
118
  ReactiveRecord::Base.load_from_json(Hash[param.collect { |key, value| [key, [value]] }], target)
115
119
  target
116
120
  end
@@ -78,6 +78,7 @@ module ReactiveRecord
78
78
  # rendering cycle completes.
79
79
  # takes care of informing react that there are things to load, and schedules the loader to run
80
80
  # Note there is no equivilent to find_in_db, because each vector implicitly does a find.
81
+ raise "attempt to do a find_by_id of nil. This will return all records, and is not allowed" if vector[1] == ["find_by_id", nil]
81
82
  unless data_loading?
82
83
  @pending_fetches << vector
83
84
  schedule_fetch
@@ -251,8 +251,9 @@ module ReactiveRecord
251
251
  new_target = target.send *method unless value.is_a? Array # value is an array if scope returns nil
252
252
  elsif value.is_a? Array
253
253
  target.send "#{method}=", value.first
254
- elsif value.is_a? Hash and value[:id] and value[:id].first
255
- new_target = target.class.reflect_on_association(method).klass.find(value[:id].first)
254
+ elsif value.is_a? Hash and value[:id] and value[:id].first #and
255
+ association = target.class.reflect_on_association(method)
256
+ new_target = association.klass.find(value[:id].first)
256
257
  target.send "#{method}=", new_target
257
258
  else
258
259
  new_target = target.send("#{method}=", target.send(method))
@@ -1,3 +1,3 @@
1
1
  module ReactiveRecord
2
- VERSION = "0.7.12"
2
+ VERSION = "0.7.13"
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.12
4
+ version: 0.7.13
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-09-07 00:00:00.000000000 Z
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails