Module: Async::Caldav::Handlers::Delete

Defined in:
lib/async/caldav/handlers/delete.rb

Class Method Summary collapse

Class Method Details

.call(path:, storage:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/async/caldav/handlers/delete.rb', line 13

def call(path:, storage:, **)
  item = storage.get_item(path.to_s)

  if item
    storage.delete_item(path.to_s)
    [204, {}, ['']]
  elsif storage.collection_exists?(path.ensure_trailing_slash.to_s)
    storage.delete_collection(path.ensure_trailing_slash.to_s)
    [204, {}, ['']]
  else
    [404, { 'content-type' => 'text/plain' }, ['Not Found']]
  end
end