lib/ecoportal/api/common/content/collection_model.rb in ecoportal-api-v2-1.1.8 vs lib/ecoportal/api/common/content/collection_model.rb in ecoportal-api-v2-2.0.0
- old
+ new
@@ -140,11 +140,11 @@
#print "^"
_doc_items.index {|item| get_key(item) == id}.tap do |p|
#print "{{#{p}}}"
end
else
- show_str = \
+ show_str =
case value
when Hash
value.pretty_inspect
when Content::DoubleModel
"#{value} with key: #{value.class.key} (items_key: #{self.class.items_key})"
@@ -327,23 +327,23 @@
_doc_items.delete_at(current_pos)
end
def _doc_upsert(value, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
- current_pos =
- if (elem = self[value])
- _doc_key(elem)
- end
+ elem = self[value]
+ current_pos = nil
+ current_pos = _doc_key(elem) if elem
pos = scope_position(pos: pos, before: before, after: after)
pos ||= current_pos
if current_pos && pos
_doc_items.delete_at(current_pos)
- pos = pos <= current_pos ? pos : pos - 1
+ pos -= 1 unless pos <= current_pos
end
- pos = (pos && pos < _doc_items.length)? pos : _doc_items.length # rubocop:disable Style/TernaryParentheses
+ pos = _doc_items.length unless pos && pos < _doc_items.length
+
pos.tap do |_i|
_doc_items.insert(pos, value)
end
end