instance method _normalize_callback_options

Ruby on Rails 3.2.22.5

Since v3.0.20

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

_normalize_callback_options(options)

If :only or :except are used, convert the options into the primitive form (:per_key) used by ActiveSupport::Callbacks. The basic idea is that :only => :index gets converted to :if => proc {|c| c.action_name == “index” }, but that the proc is only evaluated once per action for the lifetime of a Rails process.

Options

  • only - The callback should be run only for this action

  • except - The callback should be run for all actions except this action

Parameters

options req
Source
# File actionpack/lib/abstract_controller/callbacks.rb, line 33
      def _normalize_callback_options(options)
        if only = options[:only]
          only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
          options[:per_key] = {:if => only}
        end
        if except = options[:except]
          except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
          options[:per_key] = {:unless => except}
        end
      end

Defined in actionpack/lib/abstract_controller/callbacks.rb line 33 · View on GitHub · Improve this page · Find usages on GitHub

Defined in AbstractController::Callbacks::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close