Class: Samuel::Request
- Inherits:
-
Object
- Object
- Samuel::Request
- Defined in:
- lib/samuel/request.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(http, request, proc) ⇒ Request
constructor
A new instance of Request.
- #perform_and_log! ⇒ Object
Constructor Details
#initialize(http, request, proc) ⇒ Request
Returns a new instance of Request.
6 7 8 |
# File 'lib/samuel/request.rb', line 6 def initialize(http, request, proc) @http, @request, @proc = http, request, proc end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/samuel/request.rb', line 4 def response @response end |
Instance Method Details
#perform_and_log! ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/samuel/request.rb', line 10 def perform_and_log! # If an exception is raised in the Benchmark block, it'll interrupt the # benchmark. Instead, use an inner block to record it as the "response" # for raising after the benchmark (and logging) is done. @seconds = Benchmark.realtime do begin; @response = @proc.call; rescue Exception => @response; end end Samuel.logger.add(log_level, ) raise @response if @response.is_a?(Exception) end |