Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

nicer method_missings

  • Loading branch information...
commit 32e8ee4eb6f9ab643875d34e40f5ec09efcd7142 1 parent 0dc6a0a
@rkh rkh authored
View
13 lib/rack/auth/digest/request.rb
@@ -6,7 +6,6 @@ module Rack
module Auth
module Digest
class Request < Auth::AbstractRequest
-
def method
@env['rack.methodoverride.original_method'] || @env['REQUEST_METHOD']
end
@@ -27,13 +26,15 @@ def params
@params ||= Params.parse(parts.last)
end
- def method_missing(sym)
- if params.has_key? key = sym.to_s
- return params[key]
- end
- super
+ def respond_to?(sym, *)
+ super or params.has_key? sym.to_s
end
+ def method_missing(sym, *args)
+ return super unless params.has_key?(key = sym.to_s)
+ return params[key] if args.size == 0
+ raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
+ end
end
end
end
View
4 lib/rack/multipart/uploaded_file.rb
@@ -22,6 +22,10 @@ def path
end
alias_method :local_path, :path
+ def respond_to?(*args)
+ super or @tempfile.respond_to?(*args)
+ end
+
def method_missing(method_name, *args, &block) #:nodoc:
@tempfile.__send__(method_name, *args, &block)
end
Please sign in to comment.
Something went wrong with that request. Please try again.