Class: ActiveScraper::FakeHTTPartyResponse

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/active_scraper/fake_http_party_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(request, response, parsed_block = nil, options = {}) ⇒ FakeHTTPartyResponse

Returns a new instance of FakeHTTPartyResponse.



7
8
9
10
11
12
13
14
15
16
# File 'lib/active_scraper/fake_http_party_response.rb', line 7

def initialize(request, response, parsed_block=nil, options={})
  request = request.to_fake_party_hash if request.is_a?(CachedRequest)
  response = response.to_fake_party_hash if response.is_a?(CachedResponse)

  ## making HTTParty happy...

  parsed_block ||= ->(){ response.body }

  super(HTTParty::Response.new request, response, parsed_block, options)      
end