lib/roda/plugins/json.rb in roda-3.9.0 vs lib/roda/plugins/json.rb in roda-3.10.0
- old
+ new
@@ -51,20 +51,18 @@
# 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
- DEFAULT_SERIALIZER = :to_json.to_proc
-
# 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] ||= []
app.opts[:json_result_classes] += classes
app.opts[:json_result_classes].uniq!
app.opts[:json_result_classes].freeze
- app.opts[:json_result_serializer] = opts[:serializer] || app.opts[:json_result_serializer] || DEFAULT_SERIALIZER
+ app.opts[:json_result_serializer] = opts[:serializer] || app.opts[:json_result_serializer] || app.opts[:json_serializer] || :to_json.to_proc
app.opts[:json_result_include_request] = opts[:include_request] if opts.has_key?(:include_request)
app.opts[:json_result_content_type] = opts[:content_type] || 'application/json'.freeze
end