123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Callbacks

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Object
Defined in: actionpack/lib/action_dispatch/middleware/callbacks.rb

Overview

Provides callbacks to be executed before and after dispatching the request.

Constant Summary

::ActiveSupport::Callbacks - Included

CALLBACK_FILTER_TYPES

::ActiveSupport::Callbacks - Attributes & Methods

Class Method Summary

Instance Method Summary

::ActiveSupport::Callbacks - Included

#run_callbacks

Runs the callbacks for the given event.

Constructor Details

.new(app) ⇒ Callbacks

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 24

def initialize(app)
  @app = app
end

Class Attribute Details

.__callbacks (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/callbacks.rb', line 69

class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}

Class Method Details

.after(*args, &block)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 19

def after(*args, &block)
  set_callback(:call, :after, *args, &block)
end

.before(*args, &block)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 15

def before(*args, &block)
  set_callback(:call, :before, *args, &block)
end

Instance Attribute Details

#__callbacks (readonly)

[ GitHub ]

  
# File 'activesupport/lib/active_support/callbacks.rb', line 69

class_attribute :__callbacks, instance_writer: false, instance_predicate: false, default: {}

Instance Method Details

#call(env)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 28

def call(env)
  error = nil
  result = run_callbacks :call do
    @app.call(env)
  rescue => error
  end
  raise error if error
  result
end