method

define_callbacks

Importance_0
v3.0.9 - Show latest stable - 0 notes - Class: ActiveRecord::Observer
define_callbacks(klass) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/observer.rb, line 109
      def define_callbacks(klass)
        observer = self
        observer_name = observer.class.name.underscore.gsub('/', '__')

        ActiveRecord::Callbacks::CALLBACKS.each do |callback|
          next unless respond_to?(callback)
          callback_meth = :"_notify_#{observer_name}_for_#{callback}"
          unless klass.respond_to?(callback_meth)
            klass.send(:define_method, callback_meth) do
              observer.send(callback, self)
            end
            klass.send(callback, callback_meth)
          end
        end
      end
Register or log in to add new notes.