Module: Safrano::MethodHandlers

Included in:
Request
Defined in:
lib/safrano/request.rb

Overview

handle GET PUT etc

Instance Method Summary collapse

Instance Method Details

#odata_deleteObject



22
23
24
25
# File 'lib/safrano/request.rb', line 22

def odata_delete
  @walker.finalize.tap_error { |err| return err.odata_get(self) }
         .if_valid { |context| context.odata_delete(self) }
end

#odata_getObject



37
38
39
40
# File 'lib/safrano/request.rb', line 37

def odata_get
  @walker.finalize.tap_error { |err| return err.odata_get(self) }
         .if_valid { |context| context.odata_get(self) }
end

#odata_headObject



47
48
49
# File 'lib/safrano/request.rb', line 47

def odata_head
  [200, EMPTY_HASH, [EMPTY_STRING]]
end

#odata_optionsObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/safrano/request.rb', line 9

def odata_options
  # cf. stackoverflow.com/questions/22924678/sinatra-delete-response-headers
  headers.delete('Content-Type')
  @response.headers.delete('Content-Type')
  @response.headers['Content-Type'] = ''

  # we only let rack-cors handle Cors OPTIONS .
  # otherwise dont do it...
  # see https://www.mnot.net/blog/2012/10/29/NO_OPTIONS
  # 501 not implemented
  [501, EMPTY_HASH, '']
end

#odata_patchObject



32
33
34
35
# File 'lib/safrano/request.rb', line 32

def odata_patch
  @walker.finalize.tap_error { |err| return err.odata_get(self) }
         .if_valid { |context| context.odata_patch(self) }
end

#odata_postObject



42
43
44
45
# File 'lib/safrano/request.rb', line 42

def odata_post
  @walker.finalize.tap_error { |err| return err.odata_get(self) }
         .if_valid { |context| context.odata_post(self) }
end

#odata_putObject



27
28
29
30
# File 'lib/safrano/request.rb', line 27

def odata_put
  @walker.finalize.tap_error { |err| return err.odata_get(self) }
         .if_valid { |context| context.odata_put(self) }
end