lib/table_sync/receiving/handler.rb in table_sync-4.2.2 vs lib/table_sync/receiving/handler.rb in table_sync-5.0.0
- old
+ new
@@ -80,11 +80,11 @@
config.mapping_overrides(row: row).each do |before, after|
row[after] = row.delete(before)
end
- config.except(row: row).each(&row.method(:delete))
+ config.except(row: row).each { |x| row.delete(x) }
row.merge!(config.additional_data(row: row))
only = config.only(row: row)
row, rest = row.partition { |key, _| key.in?(only) }.map(&:to_h)
@@ -96,11 +96,12 @@
end.compact
end
def validate_data(data, target_keys:)
data.each do |row|
- next if target_keys.all?(&row.keys.method(:include?))
+ next if target_keys.all? { |x| row.key?(x) }
+
raise TableSync::DataError.new(
data, target_keys, "Some target keys not found in received attributes!"
)
end
@@ -108,10 +109,10 @@
raise TableSync::DataError.new(data, target_keys, "Duplicate rows found!")
end
keys_sample = data[0].keys
keys_diff = data.each_with_object(Set.new) do |row, set|
- (row.keys - keys_sample | keys_sample - row.keys).each(&set.method(:add))
+ (row.keys - keys_sample | keys_sample - row.keys).each { |x| set.add(x) }
end
unless keys_diff.empty?
raise TableSync::DataError.new(data, target_keys, <<~MESSAGE)
Bad batch structure, check keys: #{keys_diff.to_a}