Sha256: 4aeb825905d6754619fb7dd155c0fbd8e59415ceac425c829cfe1e0b9683fee1

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

begin
  require "em-http"
rescue LoadError => error
  raise "Missing EM-Synchrony dependency: gem install em-http-request"
end

module EventMachine
  class HttpRequest
     %w[get head post delete put].each do |type|
       class_eval %[
         alias :a#{type} :#{type}
         def #{type}(options = {}, &blk)
           f = Fiber.current

            conn = setup_request(:#{type}, options, &blk)
            conn.callback { f.resume(conn) }
            conn.errback  { f.resume(conn) }

            Fiber.yield
         end
      ]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-synchrony-0.2.0 lib/em-synchrony/em-http.rb
em-synchrony-0.1.5 lib/em-synchrony/em-http.rb