method

set_callbacks

set_callbacks(name, callbacks)
protected

No documentation available.

# File activesupport/lib/active_support/callbacks.rb, line 943
          def set_callbacks(name, callbacks) # :nodoc:
            # HACK: We're making assumption on how `class_attribute` is implemented
            # to save constantly duping the callback hash. If this desync with class_attribute
            # we'll lose the optimization, but won't cause an actual behavior bug.
            unless singleton_class.private_method_defined?(:__class_attr__callbacks, false)
              self.__callbacks = __callbacks.dup
            end
            name = name.to_sym
            callbacks_was = self.__callbacks[name.to_sym]
            if (callbacks_was.nil? || callbacks_was.empty?) && !callbacks.empty?
              alias_method("_run_#{name}_callbacks", "_run_#{name}_callbacks!")
            end
            self.__callbacks[name.to_sym] = callbacks
            self.__callbacks
          end