Created
April 29, 2010 21:01
-
-
Save Phrogz/384237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user_agent(pattern) | |
condition { | |
if request.user_agent =~ pattern | |
@params[:agent] = $~[1..-1] | |
true | |
else | |
false | |
end | |
} | |
end | |
alias_method :agent, :user_agent | |
def get(path, opts={}, &block) | |
conditions = @conditions.dup | |
route('GET', path, opts, &block) | |
@conditions = conditions | |
route('HEAD', path, opts, &block) | |
end | |
def route(verb, path, options={}, &block) | |
# Because of self.options.host | |
host_name(options.delete(:bind)) if options.key?(:host) | |
options.each {|option, args| send(option, *args)} | |
pattern, keys = compile(path) | |
conditions, @conditions = @conditions, [] | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment