Module: DbAgile::Restful::Middleware::Delete

Included in:
OneDatabase
Defined in:
lib/dbagile/restful/middleware/delete.rb

Instance Method Summary collapse

Instance Method Details

#delete(env) ⇒ Object

Implements DELETE access of the restful interface



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dbagile/restful/middleware/delete.rb', line 7

def delete(env)
  request = Rack::Request.new(env)
  decode(env) do |connection, table, format|
    heading = connection.heading(table)
    tuple = params_to_tuple(request.POST, heading)
    connection.transaction do |t|
      t.delete(table, tuple)
    end
    [ :json, [ JSON::generate(:ok => true) ] ]
  end
end