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 +4 -4
- data/lib/google_spreadsheets/enhanced/syncing.rb +17 -16
- data/lib/google_spreadsheets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d577ba94b3cb9c43ee71c59bb571d16d0e805a2f
|
4
|
+
data.tar.gz: 2cfcbd49f2efae6272ee2e4ad363b69d5981f2f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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(
|
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)
|
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.
|
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:
|
12
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|