Class: HTTP::CookieJar::YAMLSaver
- Inherits:
-
AbstractSaver
- Object
- AbstractSaver
- HTTP::CookieJar::YAMLSaver
- Defined in:
- lib/http/cookie_jar/yaml_saver.rb
Overview
YAMLSaver saves and loads cookies in the YAML format.
Instance Method Summary collapse
Methods inherited from AbstractSaver
class_to_symbol, implementation, inherited, #initialize
Constructor Details
This class inherits a constructor from HTTP::CookieJar::AbstractSaver
Instance Method Details
#load(io, jar) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/http/cookie_jar/yaml_saver.rb', line 11 def load(io, jar) begin data = YAML.load(io) rescue ArgumentError @logger.warn "unloadable YAML cookie data discarded" if @logger return end unless data.instance_of?(Array) @logger.warn "incompatible YAML cookie data discarded" if @logger return end data.each { || jar.add() } end |
#save(io, jar) ⇒ Object
7 8 9 |
# File 'lib/http/cookie_jar/yaml_saver.rb', line 7 def save(io, jar) YAML.dump(@session ? jar.to_a : jar.reject(&:session?), io) end |