Class: AppsignalExtensions::Middleware::TransactionClosingBody
- Inherits:
-
Object
- Object
- AppsignalExtensions::Middleware::TransactionClosingBody
- Defined in:
- lib/appsignal_extensions/middleware.rb
Overview
Acts as a wrapper for Rack response bodies. Ensures that the transaction attached to the request gets closed after the body #each returns or raises
Instance Method Summary collapse
- #close ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(body, transaction) ⇒ TransactionClosingBody
constructor
A new instance of TransactionClosingBody.
Constructor Details
#initialize(body, transaction) ⇒ TransactionClosingBody
Returns a new instance of TransactionClosingBody.
43 44 45 46 |
# File 'lib/appsignal_extensions/middleware.rb', line 43 def initialize(body, transaction) @body = body @transaction = transaction end |
Instance Method Details
#close ⇒ Object
57 58 59 |
# File 'lib/appsignal_extensions/middleware.rb', line 57 def close @body.close if @body.respond_to?(:close) end |
#each(&block) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/appsignal_extensions/middleware.rb', line 48 def each(&block) @body.each(&block) rescue Exception => e @transaction.set_error(e) raise e ensure @transaction.close end |