Class: Simple::OAuth2::Responses

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_oauth2/responses.rb

Overview

Processes Rack Responses and contains helper methods

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Responses


5
6
7
# File 'lib/simple_oauth2/responses.rb', line 5

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject


17
18
19
20
21
22
# File 'lib/simple_oauth2/responses.rb', line 17

def body
  response_body = @response[2].body.first
  return {} if response_body.nil? || response_body.empty?

  JSON.parse(response_body)
end

#headersObject


13
14
15
# File 'lib/simple_oauth2/responses.rb', line 13

def headers
  @response[1]
end

#statusObject


9
10
11
# File 'lib/simple_oauth2/responses.rb', line 9

def status
  @response[0]
end