Class: PollEverywhere::HTTP::Adapter::Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/polleverywhere/http/adapter.rb

Direct Known Subclasses

Doc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Sync

Returns a new instance of Sync.

Yields:

  • (_self)

Yield Parameters:



18
19
20
# File 'lib/polleverywhere/http/adapter.rb', line 18

def initialize
  yield self if block_given?
end

Instance Attribute Details

#requestObject

Returns the value of attribute request.



16
17
18
# File 'lib/polleverywhere/http/adapter.rb', line 16

def request
  @request
end

#responseObject

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