Class: Rack::Idempotency::Response
- Inherits:
-
Object
- Object
- Rack::Idempotency::Response
- Defined in:
- lib/rack/idempotency/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status, headers, body) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_a ⇒ Object
- #to_json ⇒ Object
Constructor Details
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/rack/idempotency/response.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/rack/idempotency/response.rb', line 6 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/rack/idempotency/response.rb', line 6 def status @status end |
Instance Method Details
#success? ⇒ Boolean
14 15 16 |
# File 'lib/rack/idempotency/response.rb', line 14 def success? status.to_i >= 200 && status.to_i < 400 end |
#to_a ⇒ Object
18 19 20 |
# File 'lib/rack/idempotency/response.rb', line 18 def to_a [status, headers.to_hash, body.each(&:to_s)] end |
#to_json ⇒ Object
22 23 24 |
# File 'lib/rack/idempotency/response.rb', line 22 def to_json to_a.to_json end |