Class: HTTP::Security::Headers::SetCookie::Cookie
- Inherits:
-
Object
- Object
- HTTP::Security::Headers::SetCookie::Cookie
- Defined in:
- lib/http/security/headers/set_cookie.rb
Instance Attribute Summary collapse
-
#cookie ⇒ Object
readonly
Returns the value of attribute cookie.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#expires ⇒ Object
readonly
Returns the value of attribute expires.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #http_only? ⇒ Boolean
-
#initialize(directives = {}) ⇒ Cookie
constructor
A new instance of Cookie.
- #name ⇒ Object
- #secure? ⇒ Boolean
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(directives = {}) ⇒ Cookie
Returns a new instance of Cookie.
21 22 23 24 25 26 27 28 |
# File 'lib/http/security/headers/set_cookie.rb', line 21 def initialize(directives={}) @cookie = directives[:cookie] @path = directives[:path] @domain = directives[:domain] @expires = directives[:expires] @secure = directives[:secure] @http_only = directives[:http_only] end |
Instance Attribute Details
#cookie ⇒ Object (readonly)
Returns the value of attribute cookie.
13 14 15 |
# File 'lib/http/security/headers/set_cookie.rb', line 13 def @cookie end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
17 18 19 |
# File 'lib/http/security/headers/set_cookie.rb', line 17 def domain @domain end |
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
19 20 21 |
# File 'lib/http/security/headers/set_cookie.rb', line 19 def expires @expires end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'lib/http/security/headers/set_cookie.rb', line 15 def path @path end |
Instance Method Details
#http_only? ⇒ Boolean
42 43 44 |
# File 'lib/http/security/headers/set_cookie.rb', line 42 def http_only? !!@http_only end |
#name ⇒ Object
30 31 32 |
# File 'lib/http/security/headers/set_cookie.rb', line 30 def name @cookie.keys.first end |
#secure? ⇒ Boolean
38 39 40 |
# File 'lib/http/security/headers/set_cookie.rb', line 38 def secure? !!@secure end |
#to_s ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/http/security/headers/set_cookie.rb', line 46 def to_s str = "#{name}=#{value}" str << "; Path=#{@path}" if @path str << "; Domain=#{@domain}" if @domain str << "; Expires=#{@expires.httpdate}" if @expires str << "; Secure" if @secure str << "; HttpOnly" if @http_only return str end |
#value ⇒ Object
34 35 36 |
# File 'lib/http/security/headers/set_cookie.rb', line 34 def value @cookie.values.first end |