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

- old
+ new

@@ -52,12 +52,14 @@ # using the +:content_type+ option: # # plugin :json, :content_type=>'application/xml' module Json OPTS = {}.freeze - DEFAULT_SERIALIZER = lambda{|o| o.to_json} + DEFAULT_SERIALIZER = :to_json.to_proc + 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) classes = opts[:classes] || [Array, Hash] app.opts[:json_result_classes] ||= [] @@ -67,10 +69,10 @@ app.opts[:json_result_serializer] = opts[:serializer] || app.opts[:json_result_serializer] || DEFAULT_SERIALIZER app.opts[:json_result_include_request] = opts[:include_request] || app.opts[:json_result_include_request] - app.opts[:json_result_content_type] = opts[:content_type] || DEFAULT_CONTENT_TYPE + app.opts[:json_result_content_type] = opts[:content_type] || 'application/json'.freeze end module ClassMethods # The classes that should be automatically converted to json def json_result_classes