lib/ecoportal/api/v1/person.rb in ecoportal-api-0.5.6 vs lib/ecoportal/api/v1/person.rb in ecoportal-api-0.5.7
- old
+ new
@@ -47,15 +47,19 @@
# @param value [Array<String>] array of tags.
def filter_tags=(value)
unless value.is_a?(Array)
raise "filter_tags= needs to be passed an Array, got #{value.class}"
end
- doc["filter_tags"] = value.map do |tag|
+ end_tags = value.map do |tag|
unless tag.match(VALID_TAG_REGEX)
raise "Invalid filter tag #{tag.inspect}"
end
tag.upcase
end
+
+ ini_tags = original_doc["filter_tags"] || []
+ # preserve original order to avoid false updates
+ doc["filter_tags"] = (ini_tags & end_tags) + (end_tags - ini_tags)
end
def as_json
super.merge "details" => details&.as_json
end