class Hurley::Test
Public Class Methods
Source
# File lib/hurley/test.rb, line 3 def initialize @handlers = [] yield self if block_given? end
Public Instance Methods
Source
# File lib/hurley/test.rb, line 40 def call(request) handler = @handlers.detect { |h| h.matches?(request) } || Handler.method(:not_found) # Create a new url with fresh state from the url string request.url = Url.parse(request.url.to_s) handler.call(request) end
Source
# File lib/hurley/test.rb, line 28 def delete(url) handle(:delete, url, &Proc.new) end
Source
# File lib/hurley/test.rb, line 36 def handle(verb, url) @handlers << Handler.new(Request.new(verb, Url.parse(url)), Proc.new) end
Source
# File lib/hurley/test.rb, line 32 def options(url) handle(:options, url, &Proc.new) end
Source
# File lib/hurley/test.rb, line 24 def patch(url) handle(:patch, url, &Proc.new) end
Source
# File lib/hurley/test.rb, line 20 def post(url) handle(:post, url, &Proc.new) end