Class: Flash::Integration::Response
- Inherits:
-
Object
- Object
- Flash::Integration::Response
- Defined in:
- lib/flash/integration/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(attributes) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 |
# File 'lib/flash/integration/response.rb', line 8 def initialize(attributes) @request = attributes.fetch(:request) @status = attributes.fetch(:status) @headers = attributes[:headers] || {} @body = attributes[:body] || {} @time = attributes[:time] || Time.now.utc end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/flash/integration/response.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/flash/integration/response.rb', line 6 def headers @headers end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/flash/integration/response.rb', line 6 def request @request end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/flash/integration/response.rb', line 6 def status @status end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
6 7 8 |
# File 'lib/flash/integration/response.rb', line 6 def time @time end |
Instance Method Details
#error? ⇒ Boolean
20 21 22 |
# File 'lib/flash/integration/response.rb', line 20 def error? !success? end |
#success? ⇒ Boolean
16 17 18 |
# File 'lib/flash/integration/response.rb', line 16 def success? @status.between?(200, 299) end |