Class: HTTP::Session::Cache::Entry
- Inherits:
-
Object
- Object
- HTTP::Session::Cache::Entry
- Defined in:
- lib/http/session/cache/entry.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
-
.deserialize(h) ⇒ Object
Deserializes from a JSON primitive type.
Instance Method Summary collapse
-
#initialize(req, res) ⇒ Entry
constructor
Returns a new instance of Entry.
-
#serialize ⇒ Object
Serializes to a JSON primitive type.
- #to_response(req) ⇒ Response
Constructor Details
#initialize(req, res) ⇒ Entry
Returns a new instance of Entry.
28 29 30 31 |
# File 'lib/http/session/cache/entry.rb', line 28 def initialize(req, res) @request = req @response = res end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
21 22 23 |
# File 'lib/http/session/cache/entry.rb', line 21 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
25 26 27 |
# File 'lib/http/session/cache/entry.rb', line 25 def response @response end |
Class Method Details
.deserialize(h) ⇒ Object
Deserializes from a JSON primitive type.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/http/session/cache/entry.rb', line 6 def deserialize(h) req = h[:req] req = HTTP::Session::Request.new(HTTP::Request.new(req)) res = h[:res] res[:request] = req res[:body] = HTTP::Session::Response::StringBody.new(res[:body]) res = HTTP::Session::Response.new(HTTP::Response.new(res)) new(req, res) end |
Instance Method Details
#serialize ⇒ Object
Serializes to a JSON primitive type.
43 44 45 46 47 48 |
# File 'lib/http/session/cache/entry.rb', line 43 def serialize { req: serialize_request, res: serialize_response } end |