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 ⇒ 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 |
# File 'lib/appsignal_extensions/middleware.rb', line 43 def initialize(body, transaction) @body, @transaction = body, transaction end |
Instance Method Details
#close ⇒ Object
56 57 58 |
# File 'lib/appsignal_extensions/middleware.rb', line 56 def close @body.close if @body.respond_to?(:close) end |
#each ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/appsignal_extensions/middleware.rb', line 47 def each @body.each{|b| yield(b) } rescue Exception => e @transaction.set_error(e) raise e ensure @transaction.close end |