Class: Rets::LockingHttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/rets/locking_http_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client, locker, lock_name, options = {}) ⇒ LockingHttpClient

Returns a new instance of LockingHttpClient.



3
4
5
6
7
8
# File 'lib/rets/locking_http_client.rb', line 3

def initialize(http_client, locker, lock_name, options={})
  @http_client = http_client
  @locker = locker
  @lock_name = lock_name
  @options = options
end

Instance Method Details

#http_get(url, params = nil, extra_headers = {}) ⇒ Object



10
11
12
13
14
# File 'lib/rets/locking_http_client.rb', line 10

def http_get(url, params=nil, extra_headers={})
  lock_around do
    @http_client.http_get(url, params, extra_headers)
  end
end

#http_post(url, params, extra_headers = {}) ⇒ Object



16
17
18
19
20
# File 'lib/rets/locking_http_client.rb', line 16

def http_post(url, params, extra_headers = {})
  lock_around do
    @http_client.http_post(url, params, extra_headers)
  end
end

#lock_around(&block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rets/locking_http_client.rb', line 26

def lock_around(&block)
  result = nil
  @locker.lock(@lock_name, @options) do
    result = block.call
  end
  result
end


22
23
24
# File 'lib/rets/locking_http_client.rb', line 22

def save_cookie_store
  @http_client.save_cookie_store
end