Skip to content

Instantly share code, notes, and snippets.

@Phrogz
Created April 29, 2010 21:01
Show Gist options
  • Save Phrogz/384237 to your computer and use it in GitHub Desktop.
Save Phrogz/384237 to your computer and use it in GitHub Desktop.
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