Class: Web::Unit::Cookies
- Includes:
- Singleton
- Defined in:
- lib/web/unit/cookie.rb
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
Class Method Summary collapse
-
.add(n, v, p = '/') ⇒ Object
— Cookies.add( name, value, path ).
-
.clear ⇒ Object
— Cookies.clear.
-
.has?(name) ⇒ Boolean
— Cookies.has?.
- .header(target) ⇒ Object
-
.list ⇒ Object
— Cookies.list.
- .update(set_cookie_response) ⇒ Object
Instance Method Summary collapse
- #add(n, v, p) ⇒ Object
- #clear ⇒ Object
- #has?(name) ⇒ Boolean
- #header(target) ⇒ Object
-
#initialize ⇒ Cookies
constructor
A new instance of Cookies.
- #list ⇒ Object
- #update(set_cookie_response) ⇒ Object
Constructor Details
#initialize ⇒ Cookies
Returns a new instance of Cookies.
16 17 18 |
# File 'lib/web/unit/cookie.rb', line 16 def initialize = {} end |
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
98 99 100 |
# File 'lib/web/unit/cookie.rb', line 98 def end |
Class Method Details
.add(n, v, p = '/') ⇒ Object
— Cookies.add( name, value, path )
36 37 38 |
# File 'lib/web/unit/cookie.rb', line 36 def self::add( n, v, p='/' ) self::instance.add( n, v, p ) end |
.clear ⇒ Object
— Cookies.clear
24 25 26 |
# File 'lib/web/unit/cookie.rb', line 24 def self::clear self::instance.clear end |
.has?(name) ⇒ Boolean
— Cookies.has?
63 64 65 |
# File 'lib/web/unit/cookie.rb', line 63 def self::has?( name ) self::instance.has?( name ) end |
.header(target) ⇒ Object
84 85 86 |
# File 'lib/web/unit/cookie.rb', line 84 def self::header( target ) self::instance.header( target ) end |
.list ⇒ Object
— Cookies.list
51 52 53 |
# File 'lib/web/unit/cookie.rb', line 51 def self::list self::instance.list end |
.update(set_cookie_response) ⇒ Object
71 72 73 |
# File 'lib/web/unit/cookie.rb', line 71 def self::update( ) self::instance.update( ) end |
Instance Method Details
#add(n, v, p) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/web/unit/cookie.rb', line 40 def add( n, v, p ) h = {} h["name"] = n h["value"] = v [[n,p]] = h end |
#clear ⇒ Object
28 29 30 |
# File 'lib/web/unit/cookie.rb', line 28 def clear = {} end |
#has?(name) ⇒ Boolean
67 68 69 |
# File 'lib/web/unit/cookie.rb', line 67 def has?( name ) .keys.collect{|x|x[0]}.include?( name ) end |
#header(target) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/web/unit/cookie.rb', line 88 def header( target ) a = [] .keys.each do |name,path| if path == nil || ( 'path=' + target ).index( path ) != nil then a.push( name + '=' + [[name,path]]["value"] ) end end a.size == 0 ? {} : { "Cookie"=>( a.join( '; ' ) ) } end |
#list ⇒ Object
55 56 57 |
# File 'lib/web/unit/cookie.rb', line 55 def list .keys.collect{|x|x[0]} end |
#update(set_cookie_response) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/web/unit/cookie.rb', line 75 def update( ) if != nil then .split(',').each do |e| c = ( e.strip ) [ [ c["name"], c["path"] ] ] = c end end end |