activeresource-google_spreadsheets 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA1:
|
3
|
-
data.tar.gz: 328a71b7b3a1ddf6cee4de5c79b9d71dca550452
|
4
|
-
metadata.gz: 4cd89573bca87047d33af66b173ac801782aa633
|
5
2
|
SHA512:
|
6
|
-
|
7
|
-
|
3
|
+
metadata.gz: b119d39d25f74629960b194a0fd970d318827306e8550f9a8617960dfd6d5ee7e53498392bc10e81cb1656493530a456d0dbc74610f856ac097f5e776549b589
|
4
|
+
data.tar.gz: ff1e75731d04d348c0226bec429e07c3fa166bac1189f2c101c7e8bd3d0706f8456a0926d570fcad07f6ca429f663dfa944c2d1952ac4fa101f94961735709e9
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: 64ad00bff2d0f3ef59dd5550c7f7d3cac7bd1de5
|
7
|
+
data.tar.gz: f3b47cc9aac71521e198234b6915b31c43cee641
|
@@ -34,6 +34,8 @@ module GoogleSpreadsheets
|
|
34
34
|
included do
|
35
35
|
class_attribute :_attr_aliases
|
36
36
|
self._attr_aliases = {}
|
37
|
+
class_attribute :_ignore_attributes
|
38
|
+
self._ignore_attributes = []
|
37
39
|
self.format = Format.new
|
38
40
|
end
|
39
41
|
|
@@ -45,6 +47,10 @@ module GoogleSpreadsheets
|
|
45
47
|
define_method("#{new_attr}=") {|*args| send("#{original_attr}=", *args) }
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
51
|
+
def ignore_column(*column_names)
|
52
|
+
self._ignore_attributes += column_names.map(&:to_s)
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
def aliased_attributes
|
@@ -56,7 +62,7 @@ module GoogleSpreadsheets
|
|
56
62
|
nil
|
57
63
|
end
|
58
64
|
end.compact
|
59
|
-
(self.class.known_attributes + gsx_attributes).uniq
|
65
|
+
(self.class.known_attributes + gsx_attributes - self.class._ignore_attributes).uniq
|
60
66
|
end
|
61
67
|
|
62
68
|
def respond_to?(method, include_priv = false)
|
@@ -32,9 +32,9 @@ module GoogleSpreadsheets
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# inbound sync all (import)
|
35
|
-
define_singleton_method("sync_with_#{rows_name}") do
|
35
|
+
define_singleton_method("sync_with_#{rows_name}") do |options = {}|
|
36
36
|
synchronizer = self.synchronizers[rows_name]
|
37
|
-
synchronizer.sync_with_rows
|
37
|
+
synchronizer.sync_with_rows(options)
|
38
38
|
end
|
39
39
|
|
40
40
|
# outbound sync one (export)
|
@@ -66,12 +66,15 @@ module GoogleSpreadsheets
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def sync_with_rows
|
69
|
+
def sync_with_rows(options)
|
70
70
|
reset
|
71
71
|
records = all_rows.map do |row|
|
72
72
|
record_class.find_or_initialize_by(id: row.id).tap do |record|
|
73
73
|
row.aliased_attributes.each do |attr|
|
74
|
-
|
74
|
+
value = row.send(attr)
|
75
|
+
if options[:include_blank] || value.present?
|
76
|
+
record.send("#{attr}=", value)
|
77
|
+
end
|
75
78
|
end
|
76
79
|
end
|
77
80
|
end
|