table_differ 0.6.0 → 0.6.2

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: 0cca324c658aebd498e3a150ef613027b416f434
4
- data.tar.gz: 78b5e10edf2b2da4ffdc209ca8ce4d8d62418db9
3
+ metadata.gz: f32849fe70818b0be853ee6ce1348076cf19b7f6
4
+ data.tar.gz: e6c63922b022bfccb5f9f69f083ca81e2a36612c
5
5
  SHA512:
6
- metadata.gz: 6238ba387974306c3e18deeac1cfebb5da47c5565e51f6905423584878068e8ebf0b61a446ccabd93cf9a91b7e53bb18bdf7084b64f5f1d586b09b5cc5dc409c
7
- data.tar.gz: c1351cd32f9e19f439bd40f47273d5405c1b24dc0184941c54d004b93294ab48905fa273c690276e38d691b48634a9a741a9b708432b1a11c2cad5e97179a943
6
+ metadata.gz: a825c536392d729a91d200d70c3fbfac19e9f6fe9ffb75f6f208d032f567fc2ad65a76d848a72a351cb6d4ee152a0364dcf2c35c64e32093d665ca6dd8bf1a23
7
+ data.tar.gz: 6f82e4c151ba2ceabb9f25d303a7568ad5096e4cb5cbd340e89c7e72a10e0ee18025c9d001bbac063fc9a8c5485142831dba5c9e75f340cdf2cefe31ddf4d617
@@ -1,3 +1,3 @@
1
1
  module TableDiffer
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.2"
3
3
  end
data/lib/table_differ.rb CHANGED
@@ -53,14 +53,16 @@ module TableDiffer
53
53
  def table_differ_remap_objects params, records
54
54
  params = Array(params)
55
55
  records.map do |record|
56
- args = params.inject({}) { |hash,key| hash[key] = record[key]; hash }
57
- real_record = where(args).first
58
- if real_record
59
- real_record.original_attributes = record.attributes
60
- real_record
61
- else
62
- record
56
+ result = record
57
+ if record.id.nil? # don't look up real ActiveRecord object if we already have one
58
+ args = params.inject({}) { |hash,key| hash[key] = record[key]; hash }
59
+ real_record = where(args).first
60
+ if real_record
61
+ real_record.original_attributes = record.attributes
62
+ result = real_record
63
+ end
63
64
  end
65
+ result
64
66
  end
65
67
  end
66
68
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_differ
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Bronson