lib/webmachine/headers.rb in webmachine-0.1.0 vs lib/webmachine/headers.rb in webmachine-0.2.0
- old
+ new
@@ -1,16 +1,25 @@
module Webmachine
- # Case-insensitive Hash of request headers
+ # Case-insensitive Hash of Request headers
class Headers < ::Hash
def [](key)
- super key.to_s.downcase
+ super transform_key(key)
end
def []=(key,value)
- super key.to_s.downcase, value
+ super transform_key(key), value
end
+ def delete(key)
+ super transform_key(key)
+ end
+
def grep(pattern)
self.class[select { |k,_| pattern === k }]
+ end
+
+ private
+ def transform_key(key)
+ key.to_s.downcase
end
end
end