lib/roda/plugins/sinatra_helpers.rb in roda-3.33.0 vs lib/roda/plugins/sinatra_helpers.rb in roda-3.34.0
- old
+ new
@@ -372,11 +372,11 @@
alias to uri
end
module ResponseMethods
# Set or retrieve the response status code.
- def status(value = (return @status; nil))
+ def status(value = nil || (return @status))
@status = value
end
# Set or retrieve the response body. When a block is given,
# evaluation is deferred until the body is needed.
@@ -399,22 +399,22 @@
super
end
# Set multiple response headers with Hash, or return the headers if no
# argument is given.
- def headers(hash = (return @headers; nil))
+ def headers(hash = nil || (return @headers))
@headers.merge!(hash)
end
# Look up a media type by file extension in Rack's mime registry.
def mime_type(type)
roda_class.mime_type(type)
end
# Set the Content-Type of the response body given a media type or file
# extension. See plugin documentation for options.
- def content_type(type = (return @headers["Content-Type"]; nil), opts = OPTS)
+ def content_type(type = nil || (return @headers["Content-Type"]), opts = OPTS)
unless (mime_type = mime_type(type) || opts[:default])
raise RodaError, "Unknown media type: #{type}"
end
unless opts.empty?
@@ -476,10 +476,10 @@
module ClassMethods
# If a type and value are given, set the value in Rack's MIME registry.
# If only a type is given, lookup the type in Rack's MIME registry and
# return it.
- def mime_type(type=(return; nil), value = nil)
+ def mime_type(type=nil || (return), value = nil)
return type.to_s if type.to_s.include?('/')
type = ".#{type}" unless type.to_s[0] == ?.
if value
Rack::Mime::MIME_TYPES[type] = value
else