Class: PollEverywhere::HTTP::Adapter::Sync
- Inherits:
-
Object
- Object
- PollEverywhere::HTTP::Adapter::Sync
- Defined in:
- lib/polleverywhere/http/adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #execute(request, &block) ⇒ Object
-
#initialize {|_self| ... } ⇒ Sync
constructor
A new instance of Sync.
Constructor Details
#initialize {|_self| ... } ⇒ Sync
Returns a new instance of Sync.
18 19 20 |
# File 'lib/polleverywhere/http/adapter.rb', line 18 def initialize yield self if block_given? end |
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
16 17 18 |
# File 'lib/polleverywhere/http/adapter.rb', line 16 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
16 17 18 |
# File 'lib/polleverywhere/http/adapter.rb', line 16 def response @response end |
Instance Method Details
#execute(request, &block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/polleverywhere/http/adapter.rb', line 22 def execute(request, &block) @request, @response = request, nil # TODO get rid of the dependency for RestClient by sucking it up and using the Ruby HTTP client RestClient::Request.execute(:method => request.method, :url => request.url.to_s, :payload => request.body, :headers => request.headers) do |r,_,_,_| @response = block.call Response.new(r.code, r.headers, r.body) end end |