lib/roda/plugins/json.rb in roda-2.28.0 vs lib/roda/plugins/json.rb in roda-2.29.0

- old
+ new

@@ -51,18 +51,19 @@ # The default content-type is 'application/json', but you can change that # using the +:content_type+ option: # # plugin :json, :content_type=>'application/xml' module Json - OPTS = {}.freeze DEFAULT_SERIALIZER = :to_json.to_proc + OPTS = {}.freeze + RodaPlugins.deprecate_constant(self, :OPTS) DEFAULT_CONTENT_TYPE = 'application/json'.freeze RodaPlugins.deprecate_constant(self, :DEFAULT_CONTENT_TYPE) # Set the classes to automatically convert to JSON, and the serializer to use. - def self.configure(app, opts=OPTS) + def self.configure(app, opts=RodaPlugins::OPTS) classes = opts[:classes] || [Array, Hash] app.opts[:json_result_classes] ||= [] app.opts[:json_result_classes] += classes app.opts[:json_result_classes].uniq! app.opts[:json_result_classes].freeze @@ -81,19 +82,20 @@ end end module RequestMethods CONTENT_TYPE = 'Content-Type'.freeze + RodaPlugins.deprecate_constant(self, :CONTENT_TYPE) private # 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. def block_result_body(result) case result when *roda_class.json_result_classes - response[CONTENT_TYPE] ||= roda_class.opts[:json_result_content_type] + response['Content-Type'] ||= roda_class.opts[:json_result_content_type] convert_to_json(result) else super end end