aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2018-01-05 16:26:38 +0100
committerTeddy Wing2018-02-07 17:02:28 +0100
commit135637edcef986f80d024b8bdbb14b33477caf7f (patch)
treed27c2e020f3d0e0b5f8cb260f35a351833b69ea6
parente07ef0eb9dac728ee5033b42c318692e2368b897 (diff)
downloadchouette-core-135637edcef986f80d024b8bdbb14b33477caf7f.tar.bz2
Edit support of list attributes
Refs #5416
-rw-r--r--app/models/concerns/checksum_support.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/concerns/checksum_support.rb b/app/models/concerns/checksum_support.rb
index a76995b0f..87218c977 100644
--- a/app/models/concerns/checksum_support.rb
+++ b/app/models/concerns/checksum_support.rb
@@ -24,10 +24,18 @@ module ChecksumSupport
self.attributes.values
end
+ def checksum_replace_nil_or_empty_values values
+ # Replace empty array by nil & nil by VALUE_FOR_NIL_ATTRIBUTE
+ values.map{ |x| x unless x.try(:empty?) }.map{ |x| x || VALUE_FOR_NIL_ATTRIBUTE }.map do |item|
+ item = item.kind_of?(Array) ? checksum_replace_nil_or_empty_values(item) : item
+ end
+ end
+
def current_checksum_source
- source = self.checksum_attributes.map{ |x| x unless x.try(:empty?) }
- source = source.map{ |x| x || VALUE_FOR_NIL_ATTRIBUTE }
- source.map(&:to_s).join(SEPARATOR)
+ source = checksum_replace_nil_or_empty_values(self.checksum_attributes)
+ source.map{ |item|
+ item = item.kind_of?(Array) ? item.map{ |x| "(#{x.join(',')})"}.join(',') : item
+ }.join(SEPARATOR)
end
def set_current_checksum_source