Class: Crawlr::CookieJar
- Inherits:
-
Object
- Object
- Crawlr::CookieJar
- Defined in:
- lib/crawlr/cookie_jar.rb
Overview
A thread-safe wrapper around the HTTP::CookieJar class
Instance Method Summary collapse
- #add(cookie) ⇒ Object
- #cookies(uri) ⇒ Object
-
#initialize ⇒ CookieJar
constructor
A new instance of CookieJar.
Constructor Details
#initialize ⇒ CookieJar
Returns a new instance of CookieJar.
8 9 10 11 |
# File 'lib/crawlr/cookie_jar.rb', line 8 def initialize @jar = HTTP::CookieJar.new @lock = Concurrent::ReadWriteLock.new end |
Instance Method Details
#add(cookie) ⇒ Object
13 14 15 |
# File 'lib/crawlr/cookie_jar.rb', line 13 def add() @lock.with_write_lock { @jar.add() } end |
#cookies(uri) ⇒ Object
17 18 19 |
# File 'lib/crawlr/cookie_jar.rb', line 17 def (uri) @lock.with_read_lock { @jar.(uri) } end |