diff options
Diffstat (limited to 'helpers.rb')
-rw-r--r-- | helpers.rb | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -83,13 +83,12 @@ helpers do json = f.read collection = JSON.parse(json) objects.each do |object| + id = object['id'] || object if delete - collection['orderedItems'].delete_if { |o| o['id'] == object['id'] } - modified = true + collection['orderedItems'].delete_if { |o| o['id'] == id or o == id } else ids = collection['orderedItems'].collect { |i| i['id'] } - collection['orderedItems'] << object unless ids.include?(object['id']) - modified = true + collection['orderedItems'] << object unless ids.include?(id) or collection['orderedItems'].include?(id) end end collection['totalItems'] = collection['orderedItems'].size |