module SoarSc::Web::Views::JSON
Public Class Methods
error()
click to toggle source
# File lib/soar_sc_views/json.rb, line 16 def self.error body = ex.message [500, {"Content-Type" => "application/json"}, [::JSON.generate(body)]] end
is_json?(data)
click to toggle source
# File lib/soar_sc_views/json.rb, line 21 def self.is_json?(data) begin ::JSON.parse(data) return true rescue => ex return false end end
not_found()
click to toggle source
# File lib/soar_sc_views/json.rb, line 12 def self.not_found [404, {}, []] end
render(http_code, body)
click to toggle source
# File lib/soar_sc_views/json.rb, line 7 def self.render(http_code, body) data = SoarSc::Web::Views::JSON::is_json?(body) ? body : ::JSON.generate(body) [http_code, {"Content-Type" => "application/json"}, [data]] end