activeresource-google_spreadsheets 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: 626c5911caadf7c19fbdd573adfbc1b9ae543086
4
- data.tar.gz: a248679186714cddcd97a03e3fbe0dbee0059f70
3
+ metadata.gz: d577ba94b3cb9c43ee71c59bb571d16d0e805a2f
4
+ data.tar.gz: 2cfcbd49f2efae6272ee2e4ad363b69d5981f2f0
5
5
  SHA512:
6
- metadata.gz: 1d9420f2494b146e3da65248c05eec4fdb1c7d32f6142b2f23f987ef8cfbe2c004954cc36666f0caeada9478431046c7513d2998b87b3b1a226b34933d6bfa31
7
- data.tar.gz: c7e8afd0c1ab9e86f8a074eb7c30e7b6230a6223fd5bb4c11c2e839f92668b406f151180c514169f977a60de8e8e0aba86df11c62a8359fbc806e6a6fec2b78f
6
+ metadata.gz: fdb59720a51c3bb45bb642da70e9d86de963e3e0dafb205e0e4b40e8395a1d4e90ebf6beeaeb174253b1713216aae95877ba526994501b68cb26371f988f606c
7
+ data.tar.gz: 18b34a972ea8c8d1905b511b1e541095762648097d16371db81af227cf8869f3223b91875d16473b5bda4a6d68d0a4823a24aaf9d8809179a5a181fb64f9481d
@@ -71,24 +71,25 @@ module GoogleSpreadsheets
71
71
 
72
72
  def sync_with_rows
73
73
  reset
74
- records = all_rows.map do |row|
75
- record_class.find_or_initialize_by(id: row.id).tap do |record|
76
- if row.all_values_empty?
77
- # Due to destroy if exists
78
- record.instance_variable_set(:@due_to_destroy, true)
79
- next
80
- end
81
-
82
- row_attributes = Hash[row.aliased_attributes.map{|attr| [attr, row.send(attr)] }]
83
- row_attributes.reject!{|_, v| v.blank? } unless @options[:include_blank]
84
- if @options[:assigner]
85
- record.send(@options[:assigner], row_attributes)
86
- else
87
- assign_row_attributes(record, row_attributes)
88
- end
74
+ records_to_save = {}
75
+ all_rows.each do |row|
76
+ record_id = row.id.to_i
77
+ record = records_to_save[record_id] || record_class.find_or_initialize_by(id: record_id)
78
+ if row.all_values_empty?
79
+ # Due to destroy if exists
80
+ record.instance_variable_set(:@due_to_destroy, true)
81
+ next
82
+ end
83
+ row_attributes = Hash[row.aliased_attributes.map{|attr| [attr, row.send(attr)] }]
84
+ row_attributes.reject!{|_, v| v.blank? } unless @options[:include_blank]
85
+ if @options[:assigner]
86
+ record.send(@options[:assigner], row_attributes)
87
+ else
88
+ assign_row_attributes(record, row_attributes)
89
89
  end
90
+ records_to_save[row.id.to_i] = record
90
91
  end
91
- skipping_outbound_sync_of(records) do |records_with_skipped_outbound|
92
+ skipping_outbound_sync_of(records_to_save.values) do |records_with_skipped_outbound|
92
93
  transaction_if_possible(record_class) do
93
94
  records_with_skipped_outbound.each do |record|
94
95
  if record.instance_variable_get(:@due_to_destroy)
@@ -1,3 +1,3 @@
1
1
  module GoogleSpreadsheets
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeresource-google_spreadsheets
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
  - Chihiro Ito
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-26 00:00:00.000000000 Z
12
+ date: 2015-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource