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

::ActiveSupport::DescendantsTracker - self

clear, descendants, direct_descendants,
store_inherited

This is the only method that is not thread safe, but is only ever called during the eager loading phase.

subclasses

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 20

def initialize(app)
  @app = app
end

Class Attribute Details

.__callbacks (rw)

[ GitHub ]

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

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

.__callbacks?Boolean (rw)

[ GitHub ]

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

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

Class Method Details

.after(*args, &block)

[ GitHub ]

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

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

.before(*args, &block)

[ GitHub ]

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

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 67

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

#__callbacks?Boolean (readonly)

[ GitHub ]

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

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

Instance Method Details

#call(env)

[ GitHub ]

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

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