Class: Stilts::Receiver
- Inherits:
-
Object
- Object
- Stilts::Receiver
- Defined in:
- lib/stilts/receiver.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Receiver
constructor
A new instance of Receiver.
- #log(level, message, response = nil) ⇒ Object
- #logger ⇒ Object
- #receive(response) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Receiver
Returns a new instance of Receiver.
4 5 |
# File 'lib/stilts/receiver.rb', line 4 def initialize( = {}) 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, , response = nil) logger.send level, LOG_PREFIX + if logger Stilts.report_environment_info Stilts.report_response_body(response.body) if response && response.respond_to?(:body) end |
#logger ⇒ Object
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 |