module Roda::RodaPlugins::Json::RequestMethods
Constants
- APPLICATION_JSON
- CONTENT_TYPE
Private Instance Methods
block_result_body(result)
click to toggle source
If the result is an instance of one of the json_result_classes, convert the result to json and return it as the body, using the application/json content-type.
Calls superclass method
# File lib/roda/plugins/json.rb, line 64 def block_result_body(result) case result when *self.class.roda_class.json_result_classes response[CONTENT_TYPE] = APPLICATION_JSON convert_to_json(result) else super end end
convert_to_json(obj)
click to toggle source
Convert the given object to JSON. Uses to_json by default, but can be overridden to use a different implementation.
# File lib/roda/plugins/json.rb, line 76 def convert_to_json(obj) obj.to_json end