Class: BombDefuser::ResponseHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/bomb_defuser/response_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser = Yajl::Parser.new) ⇒ ResponseHandler

Returns a new instance of ResponseHandler.



4
5
6
7
# File 'lib/bomb_defuser/response_handler.rb', line 4

def initialize(parser = Yajl::Parser.new)
  self.parser = parser
  self.logger = Configuration.logger
end

Instance Method Details

#process(response) ⇒ Object



9
10
11
12
13
14
# File 'lib/bomb_defuser/response_handler.rb', line 9

def process(response)
  raise(Errors::UnrecognizedResponseError, "The response can't be nil") if response.nil?

  parse(response, parser)
  result_size > 1 ? process_collection : process_single_resource
end