Module: OAuth2::ResponseObject

Included in:
ResponseArray, ResponseHash, ResponseString
Defined in:
lib/oauth2/response_object.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from(response) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/oauth2/response_object.rb', line 3

def self.from(response)
  object = MultiJson.decode(response.body)

  case object
    when Array
      ResponseArray.new(response, object)
    when Hash
      ResponseHash.new(response, object)
    else
      ResponseString.new(response)
  end
rescue
  ResponseString.new(response)
end

.included(base) ⇒ Object



18
19
20
21
22
# File 'lib/oauth2/response_object.rb', line 18

def self.included(base)
  base.class_eval do
    attr_accessor :response
  end
end

Instance Method Details

#headersObject



24
# File 'lib/oauth2/response_object.rb', line 24

def headers; response.headers end

#statusObject



25
# File 'lib/oauth2/response_object.rb', line 25

def status; response.status end