Class: BulletmarkRepairer::Rack
- Inherits:
-
Object
- Object
- BulletmarkRepairer::Rack
- Defined in:
- lib/bulletmark_repairer/rack.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
5 6 7 |
# File 'lib/bulletmark_repairer/rack.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bulletmark_repairer/rack.rb', line 9 def call(env) trace_point = TracePoint.trace(:return) do |tp| BulletmarkRepairer::Thread.memorize_methods( method_name: tp.method_id, value: tp.return_value ) end @app.call(env) ensure trace_point.disable begin if ::Thread.current[:bullet_notification_collector].notifications_present? BulletmarkRepairer::Patcher.execute( notifications: ::Thread.current[:bullet_notification_collector], controller: env['action_dispatch.request.parameters']['controller'], action: env['action_dispatch.request.parameters']['action'], loaded_associations: BulletmarkRepairer::Thread.current(:loaded_associations) ) end rescue StandardError => e raise e if BulletmarkRepairer.config.debug? end BulletmarkRepairer::Thread.clear end |