Class: One40Proof::Multi::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/one40_proof/multi/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(ad_requests, options = {}) ⇒ Base

Takes an array of hashs that build the requests. User can also specify an :on_fail option.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/one40_proof/multi/base.rb', line 11

def initialize(ad_requests, options={})
  on_fail = options[:on_fail]
  hydra = Typhoeus::Hydra.new
      
  ad_requests.each do |ad_request|
    url = build_url(ad_request.delete(:method))
  
    params = {:params => turn_keys_to_strings(ad_request)}
    request = Typhoeus::Request.new(url, params)
  
    request.on_complete do |response|
      handle_response(response, on_fail)
    end
  
    hydra.queue(request)
  end

  hydra.run
end

Instance Method Details

#adsObject



31
32
33
# File 'lib/one40_proof/multi/base.rb', line 31

def ads
  @ads ||= []
end