Class: Brief::Server::Handlers::Modify

Inherits:
Object
  • Object
show all
Defined in:
lib/brief/server/handlers/modify.rb

Defined Under Namespace

Classes: Writer

Class Method Summary collapse

Class Method Details

.handle(path_args, briefcase, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/brief/server/handlers/modify.rb', line 3

def self.handle(path_args, briefcase, options={})
  action = options.fetch(:action)
  request = options.fetch(:request)

  writer = Writer.new(briefcase, path_args, request.params.symbolize_keys)

  headers = {"Content-Type"=>"application/json", "X-BRIEF-MODIFY-ACTION"=>action}

  response = writer.run(action)

  if writer.has_errors?
    [500, headers, {errors: writer.errors, path: path_args}]
  else
    [200, headers, response]
  end
end