Class: Medusa::CookieStore
- Inherits:
-
Hash
- Object
- Hash
- Medusa::CookieStore
- Defined in:
- lib/medusa/cookie_store.rb
Instance Method Summary collapse
-
#initialize(cookies = nil) ⇒ CookieStore
constructor
A new instance of CookieStore.
- #merge!(set_cookie_str) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cookies = nil) ⇒ CookieStore
Returns a new instance of CookieStore.
13 14 15 16 17 |
# File 'lib/medusa/cookie_store.rb', line 13 def initialize( = nil) @cookies = {} .each { |name, value| @cookies[name] = WEBrick::Cookie.new(name, value) } if super(@cookies) end |
Instance Method Details
#merge!(set_cookie_str) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/medusa/cookie_store.rb', line 19 def merge!() begin = WEBrick::Cookie.().inject({}) do |hash, | hash[.name] = if !! hash end @cookies.merge! rescue end end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/medusa/cookie_store.rb', line 30 def to_s @cookies.values.reject { || .expired? }.map { || "#{.name}=#{.value}" }.join(';') end |