class Grape::OAuth2::Responses::Base
Base
class for Grape::OAuth2
endpoints responses. Processes raw Rack Responses
and contains helper methods.
Attributes
rack_response[R]
Raw Rack::Response to process
@return [Array] Rack response
@example
response = Grape::OAuth2::Responses::Base.new([200, {}, Rack::BodyProxy.new('Test')]) response.rack_response #=> [200, {}, Rack::BodyProxy.new('Test')]
Public Class Methods
new(rack_response)
click to toggle source
OAuth2
response class.
@param rack_response
[Array]
raw Rack::Response object
# File lib/grape_oauth2/responses/base.rb, line 25 def initialize(rack_response) # Rack Body: # [Status Code, Headers, Body] @rack_response = rack_response end
Public Instance Methods
body()
click to toggle source
JSON-parsed body
# File lib/grape_oauth2/responses/base.rb, line 47 def body response_body = raw_body.first return {} if response_body.nil? || response_body.empty? JSON.parse(response_body) end
headers()
click to toggle source
Response headers
# File lib/grape_oauth2/responses/base.rb, line 37 def headers @rack_response[1] end
raw_body()
click to toggle source
Raw Rack body
# File lib/grape_oauth2/responses/base.rb, line 42 def raw_body @rack_response[2].body end
status()
click to toggle source
Response status
# File lib/grape_oauth2/responses/base.rb, line 32 def status @rack_response[0] end