Skip to content

Commit

Permalink
Remove code for built-in route conditions
Browse files Browse the repository at this point in the history
Note that the :host option still requires special
handling because options can comflict with options.
Is it a code smell?
  • Loading branch information
sr authored and rtomayko committed May 18, 2009
1 parent ecdd24a commit bd11d9c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/sinatra/base.rb
Expand Up @@ -729,8 +729,9 @@ def user_agent(pattern)
end
}
end
alias_method :agent, :user_agent

def accept_mime_types(types)
def provides(*types)
types = [types] unless types.kind_of? Array
types.map!{|t| media_type(t)}

Expand Down Expand Up @@ -762,11 +763,11 @@ def delete(path, opts={}, &bk); route 'DELETE', path, opts, &bk end
def head(path, opts={}, &bk); route 'HEAD', path, opts, &bk end

private
def route(verb, path, opts={}, &block)
host_name opts.delete(:host) if opts.key?(:host)
user_agent opts.delete(:agent) if opts.key?(:agent)
accept_mime_types opts.delete(:provides) if opts.key?(:provides)
opts.each {|o, args| send(o, *args)}
def route(verb, path, options={}, &block)
options.each {|option, args| send(option, *args)}

# Because of self.options.host
host_name(options[:host]) if options.key?(:host)

pattern, keys = compile(path)
conditions, @conditions = @conditions, []
Expand Down

0 comments on commit bd11d9c

Please sign in to comment.