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 +4 -4
- data/lib/table_differ/version.rb +1 -1
- data/lib/table_differ.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f32849fe70818b0be853ee6ce1348076cf19b7f6
|
4
|
+
data.tar.gz: e6c63922b022bfccb5f9f69f083ca81e2a36612c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a825c536392d729a91d200d70c3fbfac19e9f6fe9ffb75f6f208d032f567fc2ad65a76d848a72a351cb6d4ee152a0364dcf2c35c64e32093d665ca6dd8bf1a23
|
7
|
+
data.tar.gz: 6f82e4c151ba2ceabb9f25d303a7568ad5096e4cb5cbd340e89c7e72a10e0ee18025c9d001bbac063fc9a8c5485142831dba5c9e75f340cdf2cefe31ddf4d617
|
data/lib/table_differ/version.rb
CHANGED
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
real_record
|
60
|
-
real_record
|
61
|
-
|
62
|
-
|
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
|
|