Class: Capybara::Lightpanda::Cookies::Cookie
- Inherits:
-
Object
- Object
- Capybara::Lightpanda::Cookies::Cookie
- Defined in:
- lib/capybara/lightpanda/cookies.rb
Overview
Typed wrapper around a CDP cookie hash so callers don’t have to remember the camelCase keys (‘httpOnly`, `sameSite`, …) the CDP returns. Mirrors ferrum’s Cookies::Cookie. ‘attributes` exposes the raw hash for callers that still need it (e.g. YAML serialization in store/load).
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #domain ⇒ Object
-
#expires ⇒ Object
Time when the cookie expires, or nil for session cookies (CDP reports session cookies with ‘expires: -1`).
- #hash ⇒ Object
- #httponly? ⇒ Boolean (also: #http_only?)
-
#initialize(attributes) ⇒ Cookie
constructor
A new instance of Cookie.
- #name ⇒ Object
- #path ⇒ Object
- #samesite ⇒ Object (also: #same_site)
- #secure? ⇒ Boolean
- #session? ⇒ Boolean
- #size ⇒ Object
- #to_h ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Cookie
Returns a new instance of Cookie.
15 16 17 |
# File 'lib/capybara/lightpanda/cookies.rb', line 15 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
13 14 15 |
# File 'lib/capybara/lightpanda/cookies.rb', line 13 def attributes @attributes end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
39 40 41 |
# File 'lib/capybara/lightpanda/cookies.rb', line 39 def ==(other) other.is_a?(self.class) && other.attributes == attributes end |
#domain ⇒ Object
21 |
# File 'lib/capybara/lightpanda/cookies.rb', line 21 def domain = attributes["domain"] |
#expires ⇒ Object
Time when the cookie expires, or nil for session cookies (CDP reports session cookies with ‘expires: -1`).
34 35 36 37 |
# File 'lib/capybara/lightpanda/cookies.rb', line 34 def expires exp = attributes["expires"] Time.at(exp) if exp.is_a?(Numeric) && exp.positive? end |
#hash ⇒ Object
45 46 47 |
# File 'lib/capybara/lightpanda/cookies.rb', line 45 def hash attributes.hash end |
#httponly? ⇒ Boolean Also known as: http_only?
26 |
# File 'lib/capybara/lightpanda/cookies.rb', line 26 def httponly? = attributes["httpOnly"] |
#name ⇒ Object
19 |
# File 'lib/capybara/lightpanda/cookies.rb', line 19 def name = attributes["name"] |
#path ⇒ Object
22 |
# File 'lib/capybara/lightpanda/cookies.rb', line 22 def path = attributes["path"] |
#samesite ⇒ Object Also known as: same_site
23 |
# File 'lib/capybara/lightpanda/cookies.rb', line 23 def samesite = attributes["sameSite"] |
#secure? ⇒ Boolean
25 |
# File 'lib/capybara/lightpanda/cookies.rb', line 25 def secure? = attributes["secure"] |
#session? ⇒ Boolean
27 |
# File 'lib/capybara/lightpanda/cookies.rb', line 27 def session? = attributes["session"] |
#size ⇒ Object
24 |
# File 'lib/capybara/lightpanda/cookies.rb', line 24 def size = attributes["size"] |
#to_h ⇒ Object
49 50 51 |
# File 'lib/capybara/lightpanda/cookies.rb', line 49 def to_h attributes end |
#value ⇒ Object
20 |
# File 'lib/capybara/lightpanda/cookies.rb', line 20 def value = attributes["value"] |