Class: Stilts::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/stilts/receiver.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Receiver

Returns a new instance of Receiver.



4
5
# File 'lib/stilts/receiver.rb', line 4

def initialize(options = {})
end

Instance Method Details

#log(level, message, response = nil) ⇒ Object



22
23
24
25
26
# File 'lib/stilts/receiver.rb', line 22

def log(level, message, response = nil)
  logger.send level, LOG_PREFIX + message if logger
  Stilts.report_environment_info
  Stilts.report_response_body(response.body) if response && response.respond_to?(:body)
end

#loggerObject



18
19
20
# File 'lib/stilts/receiver.rb', line 18

def logger
  Stilts.configuration.logger
end

#receive(response) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/stilts/receiver.rb', line 7

def receive(response)
  case response
  when Net::HTTPSuccess then
    log :info, "Success: #{response.class}", response
    
    return JSON.parse(response.body)
  else
    log :error, "Failure: #{response.class}", response
  end
end