Sha256: 8150961ad1b7f1ff4947a5e2ac89b871d1d6a32aba23c41055fa3a5d94b542e0
Contents?: true
Size: 765 Bytes
Versions: 1
Compression:
Stored size: 765 Bytes
Contents
require 'amazon_product' require 'em-synchrony' require 'em-synchrony/em-http' # Patches Request and Response to make them fiber-aware. module AmazonProduct class Request def adapter @adapter ||= EM::HttpRequest end # Performs an evented request. # # Yields a response to given block. def aget(&block) http = EM::HttpRequest.new(url).aget http.callback { block.call(Response.new(http)) } http.errback { block.call(Response.new(http)) } end # Performs an evented request. def get http = EM::HttpRequest.new(url).get Response.new(http) end end class Response def initialize(http) self.body = http.response self.code = http.response_header.status end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
amazon_product-3.0.0.pre.1 | lib/amazon_product/synchrony.rb |