Skip to content
Browse files

Allowed accept matchers to take non-arrays.

  • Loading branch information...
1 parent 386122e commit ac9bd4eb2ed3a5e507397f400c155e0ece902ecd Dan Yoder committed Jul 13, 2009
Showing with 10 additions and 13 deletions.
  1. +10 −13 lib/waves/matchers/accept.rb
View
23 lib/waves/matchers/accept.rb
@@ -12,19 +12,16 @@ class Accept
def initialize(options)
@constraints = {}
-
- # Default to accepting text/html
- if options[:accept] and !options[:accept].empty?
- @constraints[:accept] = options[:accept]
- end
-
- if options[:charset] and !options[:charset].empty?
- @constraints[:accept_charset] = options[:charset]
- end
-
- if options[:lang] and !options[:lang].empty?
- @constraints[:accept_language] = options[:lang]
- end
+
+ { :accept => :accept, :charset => :accept_charset, :lang => :accept_lang }.each { |key,method|
+ if options[key]
+ if options[key].is_a? Array
+ @constraints[method] = options[key] unless options[key].empty?
+ else
+ @constraints[method] = [ options[key] ]
+ end
+ end
+ }
end

0 comments on commit ac9bd4e

Please sign in to comment.
Something went wrong with that request. Please try again.