Class: HTTP::CookieJar::AbstractSaver

Inherits:
Object
  • Object
show all
Defined in:
lib/http/cookie_jar/abstract_saver.rb

Overview

An abstract superclass for all saver classes.

Direct Known Subclasses

CookiestxtSaver, YAMLSaver

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ AbstractSaver

:call-seq:

new(**options)

Called by the constructor of each subclass using super().



27
28
29
30
31
32
33
34
35
36
# File 'lib/http/cookie_jar/abstract_saver.rb', line 27

def initialize(options = nil)
  options ||= {}
  @logger  = options[:logger]
  @session = options[:session]
  # Initializes each instance variable of the same name as option
  # keyword.
  default_options.each_pair { |key, default|
    instance_variable_set("@#{key}", options.fetch(key, default))
  }
end

Class Method Details

.implementation(symbol) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/http/cookie_jar/abstract_saver.rb', line 6

def self.implementation(symbol)
  case symbol
  when :yaml
    HTTP::CookieJar::YAMLSaver
  when :cookiestxt
    HTTP::CookieJar::CookiestxtSaver
  else
    raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
  end
end

Instance Method Details

#load(io, jar) ⇒ Object

Implements HTTP::CookieJar#load().

This is an abstract method that each subclass must override.



48
49
50
# File 'lib/http/cookie_jar/abstract_saver.rb', line 48

def load(io, jar)
  # self
end

#save(io, jar) ⇒ Object

Implements HTTP::CookieJar#save().

This is an abstract method that each subclass must override.



41
42
43
# File 'lib/http/cookie_jar/abstract_saver.rb', line 41

def save(io, jar)
  # self
end