Class: Morpheus::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/morpheus/response_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, request, metadata) ⇒ ResponseParser

Returns a new instance of ResponseParser.



4
5
6
7
8
9
# File 'lib/morpheus/response_parser.rb', line 4

def initialize(owner, request, )
  @requesting_class = owner
  @request          = request
  @response         = request.response
  @metadata         = 
end

Class Method Details

.parse(owner, request, metadata) ⇒ Object



11
12
13
# File 'lib/morpheus/response_parser.rb', line 11

def self.parse(owner, request, )
  new(owner, request, ).parse
end

Instance Method Details

#parseObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/morpheus/response_parser.rb', line 15

def parse
  clear_cache!
  with_active_support_notifications do
    case @response.code
    when 200..299, 422
      build_from_response
    when 404
      raise_not_found
    when 500..599
      raise ServerError
    when 0
      raise RemoteHostConnectionFailure
    else
      raise InvalidResponseCode, "Response had error code: #{@response.code}"
    end
  end
end