123456789_123456789_123456789_123456789_123456789_

Module: AbstractController::Callbacks

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Defined in: actionpack/lib/abstract_controller/callbacks.rb

Overview

Abstract Controller provides hooks during the life cycle of a controller action. Callbacks allow you to trigger logic during this cycle. Available callbacks are:

  • after_action

  • append_after_action

  • append_around_action

  • append_before_action

  • around_action

  • before_action

  • prepend_after_action

  • prepend_around_action

  • prepend_before_action

  • skip_after_action

  • skip_around_action

  • skip_before_action

NOTE: Calling the same callback multiple times will overwrite previous callback definitions.

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

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

Instance Method Summary

  • #process_action

    Override Base#process_action to run the process_action callbacks around the normal behavior.

::ActiveSupport::Callbacks - Included

#run_callbacks

Runs the callbacks for the given event.

DSL Calls

included

[ GitHub ]


32
33
34
35
36
# File 'actionpack/lib/abstract_controller/callbacks.rb', line 32

included do
  define_callbacks :process_action,
                   terminator: ->(controller, result_lambda) { result_lambda.call; controller.performed? },
                   skip_after_callbacks_if_terminated: true
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: {}

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

#process_action

Override Base#process_action to run the process_action callbacks around the normal behavior.

[ GitHub ]

  
# File 'actionpack/lib/abstract_controller/callbacks.rb', line 40

def process_action(*)
  run_callbacks(:process_action) do
    super
  end
end