Permalink
Browse files

Remove uneccessary line from provieds, use do ... end for multiline c…

…onditions.
  • Loading branch information...
rkh committed Sep 22, 2010
1 parent 3e0c8cb commit fd5df5a6db65a69830de70e08a6c7924ae3517d4
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/sinatra/base.rb
View
@@ -878,31 +878,30 @@ def host_name(pattern)
# Condition for matching user agent. Parameter should be Regexp.
# Will set params[:agent].
def user_agent(pattern)
- condition {
+ condition do
if request.user_agent =~ pattern
@params[:agent] = $~[1..-1]
true
else
false
end
- }
+ end
end
alias_method :agent, :user_agent
# Condition for matching mimetypes. Accepts file extensions.
def provides(*types)
- types = [types] unless types.kind_of? Array
- types.map!{|t| mime_type(t)}
+ types.map! { |t| mime_type(t) }
- condition {
+ condition do
matching_types = (request.accept & types)
unless matching_types.empty?
response.headers['Content-Type'] = matching_types.first
true
else
false
end
- }
+ end
end
public

0 comments on commit fd5df5a

Please sign in to comment.