Sha256: 00fb95b40f60a3232de64493034d7d2eb2ad0af3b8a3592a904e51f90e42436c

Contents?: true

Size: 454 Bytes

Versions: 3

Compression:

Stored size: 454 Bytes

Contents

require 'vacuum'
require 'em-http-request'

module Vacuum
  class Request
    # Performs an async request.
    #
    # @yield Passes response to given block
    def aget(&blk)
      http = EM::HttpRequest.new(url).get
      http.callback { blk.call _response(http) }
      http.errback  { blk.call _response(http) }

      nil
    end

    private

    def _response(http)
      Response.new(http.response, http.response_header.status)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vacuum-0.1.2 lib/vacuum/em.rb
vacuum-0.1.1 lib/vacuum/em.rb
vacuum-0.1.0 lib/vacuum/em.rb