lib/carte/server.rb in carte-server-1.0.8 vs lib/carte/server.rb in carte-server-1.0.9

- old
+ new

@@ -133,9 +133,26 @@ get '/tags.json' do {tags: Card.all_tags}.to_json end + put '/tags/:name.json' do + # TODO: existence and length validation + if json_data['new_name'] + cards = Card.collection.where(tags: params[:name]) + cards.update( + {'$push' => {tags: json_data['new_name']}}, + {:multi => true} + ) + cards.update( + {'$pull' => {tags: params[:name]}}, + {:multi => true} + ) + end + status 201 + {}.to_json + end + error(404) do {}.to_json end end end