activerecord_data_importer 0.1.2 → 0.1.3

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: 8c6e121d04fedadc485969608f9a3059d4bd5a86
4
- data.tar.gz: 81c0bec1c4c07881ed4309bfe01ca4d84d828da2
3
+ metadata.gz: 9ad392f5c9ba5ebd15c3344e2eed15f5295d3178
4
+ data.tar.gz: 37a7251dd85dda331ff59ecff58741931d0054bb
5
5
  SHA512:
6
- metadata.gz: a898b0a8f735cef8a9f970391c4d7225e30f7da6286e62716eb5ea6636196687b6ad5e442053b6dd4e20119f2b973de3eb96315341b357fa85c363bcbddae0cd
7
- data.tar.gz: a411a87e7cab4a05427b32ed0848e7e7af88224657e0d81417c8f0f34c01c695c33bf20c0c572f47359347ea2ab11852f488c3147edf576a74ac3d6181cfb3c0
6
+ metadata.gz: 32c1eeba66d812b17bb917731bf08a50376b2e61067b57e91b2eea839ac97075e559767af6771cd5018b61f7a80e1f9ba05da803a614e1d5fc20a7a124cdde54
7
+ data.tar.gz: 01f188c6eb48318e5f6bae1b4091f8478e7e38e79d0543e0cb752bc9171bdd1405fb842beb4413f69f78a3adeb469ec7e31b782c8076b819082db7e3c442ce89
@@ -74,6 +74,8 @@ module ActiverecordDataImporter
74
74
  self_attributes, another_attributes = self.class.divide_attributes row_data
75
75
  origin_updated = self.update_origin self_attributes, latest_version
76
76
  return origin_updated if another_attributes.blank?
77
+ relation_attributes = self.class.divide_relation_key another_attributes
78
+ return origin_updated if relation_attributes.blank?
77
79
  relation_updated = self.update_relation another_attributes
78
80
  if (!origin_updated && relation_updated)
79
81
  self.update_with_version latest_version
@@ -91,15 +93,15 @@ module ActiverecordDataImporter
91
93
  true
92
94
  end
93
95
 
94
- def update_relation(another_attributes)
96
+ def update_relation(all_relation_attributes)
95
97
  latest_version = self.class.get_latest_version
96
- self.class.divide_relation_key(another_attributes).select do |key, value|
97
- case value
98
- when Hash
99
- relation_instance = self.try(key) || self.try("build_#{key}")
100
- relation_instance.update_row_data value, latest_version
101
- when Array
102
- relation_instances = self.try(key).to_a
98
+ all_relation_attributes.select do |key, value|
99
+ case value
100
+ when Hash
101
+ relation_instance = self.try(key) || self.try("build_#{key}")
102
+ relation_instance.update_row_data value, latest_version
103
+ when Array
104
+ relation_instances = self.try(key).to_a
103
105
  updated_flag = false
104
106
  value.each_with_index do |relation_attributes, i|
105
107
  relation_instance = relation_instances[i] || self.try(key).build
@@ -1,3 +1,3 @@
1
1
  module ActiverecordDataImporter
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_data_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ukayare
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'ActiverecordDataImporter is enable to load and import file (format is
14
14
  csv, json) for ActiveRecord''s model. For example, when you must use and import