Guest User

Untitled

a guest
May 24th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def user_agent(pattern)
  2. condition {
  3. if request.user_agent =~ pattern
  4. @params[:agent] = $~[1..-1]
  5. true
  6. else
  7. false
  8. end
  9. }
  10. end
  11. alias_method :agent, :user_agent
  12.  
  13. def get(path, opts={}, &block)
  14. conditions = @conditions.dup
  15. route('GET', path, opts, &block)
  16.  
  17. @conditions = conditions
  18. route('HEAD', path, opts, &block)
  19. end
  20.  
  21. def route(verb, path, options={}, &block)
  22. # Because of self.options.host
  23. host_name(options.delete(:bind)) if options.key?(:host)
  24.  
  25. options.each {|option, args| send(option, *args)}
  26.  
  27. pattern, keys = compile(path)
  28. conditions, @conditions = @conditions, []
  29. ...
Add Comment
Please, Sign In to add comment