mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Fix hand-made autoloading to allow directly referencing MozillaStore.
This commit is contained in:
parent
ded02f8327
commit
d806955f57
2 changed files with 22 additions and 1 deletions
|
|
@ -9,6 +9,27 @@ class HTTP::CookieJar
|
|||
require 'http/cookie_jar/abstract_store'
|
||||
require 'http/cookie_jar/abstract_saver'
|
||||
|
||||
class << self
|
||||
def const_missing(name)
|
||||
case name.to_s
|
||||
when /\A([A-Za-z]+)Store\z/
|
||||
file = 'http/cookie_jar/%s_store' % $1.downcase
|
||||
when /\A([A-Za-z]+)Saver\z/
|
||||
file = 'http/cookie_jar/%s_saver' % $1.downcase
|
||||
end
|
||||
begin
|
||||
require file
|
||||
rescue LoadError => e
|
||||
raise NameError, 'can\'t resolve constant %s; failed to load %s' % [name, file]
|
||||
end
|
||||
if const_defined?(name)
|
||||
const_get(name)
|
||||
else
|
||||
raise NameError, 'can\'t resolve constant %s after loading %s' % [name, file]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
attr_reader :store
|
||||
|
||||
# Generates a new cookie jar.
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class HTTP::CookieJar
|
|||
|
||||
@filename = options[:filename] or raise ArgumentError, ':filename option is missing'
|
||||
|
||||
@sjar = HashStore.new
|
||||
@sjar = HTTP::CookieJar::HashStore.new
|
||||
|
||||
@db = Database.new(@filename)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue