Class: BetterAuth::Response
- Inherits:
-
Object
- Object
- BetterAuth::Response
- Defined in:
- lib/better_auth/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.
Class Method Summary collapse
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(status:, headers:, body:) ⇒ Response
constructor
A new instance of Response.
- #json(**options) ⇒ Object
- #to_a ⇒ Object (also: #to_ary)
Constructor Details
#initialize(status:, headers:, body:) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 |
# File 'lib/better_auth/response.rb', line 9 def initialize(status:, headers:, body:) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/better_auth/response.rb', line 7 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/better_auth/response.rb', line 7 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/better_auth/response.rb', line 7 def status @status end |
Class Method Details
.from_rack(tuple) ⇒ Object
15 16 17 18 |
# File 'lib/better_auth/response.rb', line 15 def self.from_rack(tuple) status, headers, body = tuple new(status: status, headers: headers, body: body) end |
Instance Method Details
#[](index) ⇒ Object
30 31 32 |
# File 'lib/better_auth/response.rb', line 30 def [](index) to_a[index] end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/better_auth/response.rb', line 26 def each(&block) to_a.each(&block) end |
#first ⇒ Object
34 35 36 |
# File 'lib/better_auth/response.rb', line 34 def first status end |
#json(**options) ⇒ Object
38 39 40 |
# File 'lib/better_auth/response.rb', line 38 def json(**) JSON.parse(body.join, **) end |
#to_a ⇒ Object Also known as: to_ary
20 21 22 |
# File 'lib/better_auth/response.rb', line 20 def to_a [status, headers, body] end |