summaryrefslogtreecommitdiff
path: root/helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.rb')
-rw-r--r--helpers.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/helpers.rb b/helpers.rb
index 84f6a89..3e24b82 100644
--- a/helpers.rb
+++ b/helpers.rb
@@ -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