Module: SoarSc::Web::Views::Default

Includes:
Jsender
Defined in:
lib/soar_sc_views/default.rb

Class Method Summary collapse

Class Method Details

.error(ex) ⇒ Object



29
30
31
32
# File 'lib/soar_sc_views/default.rb', line 29

def self.error(ex)
  body = ex.is_a?(Exception) ? ex.message : ex.to_s
  [500, {"Content-Type" => "text/html"}, [body]]
end

.not_authenticatedObject



17
18
19
# File 'lib/soar_sc_views/default.rb', line 17

def self.not_authenticated
  [401, {}, ["401 - Not authenticated"]]
end

.not_authorizedObject



21
22
23
# File 'lib/soar_sc_views/default.rb', line 21

def self.not_authorized
  [403, {}, [" 403 - Not authorized"]]
end

.not_foundObject



13
14
15
# File 'lib/soar_sc_views/default.rb', line 13

def self.not_found
  [404, {}, ["404 - Not found"]]
end

.not_valid(errors) ⇒ Object



25
26
27
# File 'lib/soar_sc_views/default.rb', line 25

def self.not_valid(errors)
  [400, {"Content-Type" => "application/json"} , errors]
end

.render(http_code, body) ⇒ Object



9
10
11
# File 'lib/soar_sc_views/default.rb', line 9

def self.render(http_code, body)
  [http_code, {"Content-Type" => "text/html"}, [body]]
end