lib/httpx/plugins/cookies/jar.rb in httpx-0.15.4 vs lib/httpx/plugins/cookies/jar.rb in httpx-0.16.0
- old
+ new
@@ -55,11 +55,11 @@
end
def each(uri = nil, &blk)
return enum_for(__method__, uri) unless block_given?
- return @store.each(&blk) unless uri
+ return @cookies.each(&blk) unless uri
uri = URI(uri)
now = Time.now
tpath = uri.path
@@ -70,9 +70,28 @@
else
yield cookie if cookie.valid_for_uri?(uri) && Cookie.path_match?(cookie.path, tpath)
false
end
end
+ end
+
+ def merge(other)
+ cookies_dup = dup
+
+ other.each do |elem|
+ cookie = case elem
+ when Cookie
+ elem
+ when Array
+ Cookie.new(*elem)
+ else
+ Cookie.new(elem)
+ end
+
+ cookies_dup.add(cookie)
+ end
+
+ cookies_dup
end
end
end
end