Sha256: a31bf6d45a0441333d2775910b75e565e3e0b3d800587e1650f8cb35c577ee85
Contents?: true
Size: 679 Bytes
Versions: 89
Compression:
Stored size: 679 Bytes
Contents
module Brief::Server::Handlers class Action def self.handle(path_args, briefcase, options={}) parts = path_args.split("/") action = parts.shift path = parts.join("/") document = briefcase.document_at(path) headers = { "Content-Type" => "application/json" } if !document return [404,headers,{error:"Could not find a document at this path"}] end model = document.to_model if !model.class.defined_actions.include?(action.to_sym) [400, headers, {error:"Invalid action: #{ action }"}] else model.send(action) [200, headers, model.as_json] end end end end
Version data entries
89 entries across 89 versions & 1 rubygems